1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #5885 from turbo124/v5-develop

Fixes for CORS
This commit is contained in:
David Bomba 2021-06-02 09:08:07 +10:00 committed by GitHub
commit 8baaaa10c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 42 deletions

View File

@ -41,7 +41,6 @@ use App\Http\Middleware\TrustProxies;
use App\Http\Middleware\UrlSetDb;
use App\Http\Middleware\UserVerified;
use App\Http\Middleware\VerifyCsrfToken;
use App\Http\Middleware\WebCors;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
@ -73,7 +72,6 @@ class Kernel extends HttpKernel
TrustProxies::class,
// \Fruitcake\Cors\HandleCors::class,
Cors::class,
WebCors::class,
];
@ -87,12 +85,10 @@ class Kernel extends HttpKernel
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
QueryLogging::class,
WebCors::class,
],
'api' => [
@ -167,6 +163,7 @@ class Kernel extends HttpKernel
protected $middlewarePriority = [
Cors::class,
SetDomainNameDb::class,
SetDb::class,
SetWebDb::class,

View File

@ -28,6 +28,6 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
//
'livewire/message/*'
];
}

View File

@ -1,36 +0,0 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Response;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class WebCors
{
public function handle($request, Closure $next)
{
if ($request->getMethod() == 'OPTIONS') {
header('Access-Control-Allow-Origin: *');
// ALLOW OPTIONS METHOD
$headers = [
'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
'Access-Control-Allow-Headers'=> 'X-API-COMPANY-KEY,X-CLIENT-VERSION,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,X-CSRF-TOKEN,X-LIVEWIRE',
];
return Response::make('OK', 200, $headers);
}
$response = $next($request);
$response->headers->set('Access-Control-Allow-Origin', $request->getSchemeAndHttpHost());
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', 'X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,X-CSRF-TOKEN,X-LIVEWIRE');
$response->headers->set('Access-Control-Expose-Headers', 'X-APP-VERSION,X-MINIMUM-CLIENT-VERSION');
$response->headers->set('X-APP-VERSION', config('ninja.app_version'));
$response->headers->set('X-MINIMUM-CLIENT-VERSION', config('ninja.minimum_client_version'));
return $response;
}
}

View File

@ -44,7 +44,7 @@ class SchedulerCheck implements ShouldQueue
{
try {
Artisan::call('migrate', ['--force' => true]);
Artisan::call('migrate', ['--force' => 'true']);
} catch (\Exception $e) {
nlog("I wasn't able to migrate the data.");
nlog($e->getMessage());