Skip to content

Commit a990350

Browse files
authored
Merge pull request #33 from utilewebsites/master
Fix origin denied issue by trimming trailing slash from APP_URL and H…
2 parents e093609 + ce6c0cf commit a990350

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Http/Middleware/TinymceMiddleware.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ public function handle($request, Closure $next)
2222
/**
2323
* Check if the request coming from the same origin
2424
*/
25-
$accepted_origins = [config('app.url')];
26-
if (isset($_SERVER['HTTP_ORIGIN'])) {
27-
if (in_array($_SERVER['HTTP_ORIGIN'], $accepted_origins)) {
28-
header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
25+
$accepted_origins = [rtrim(config('app.url'), '/')];
26+
$origin = rtrim($_SERVER['HTTP_ORIGIN'], '/');
27+
28+
if (isset($origin)) {
29+
if (in_array($origin, $accepted_origins)) {
30+
header('Access-Control-Allow-Origin: ' . $origin);
2931
} else {
3032
header('HTTP/1.1 403 Origin Denied');
31-
3233
return response()->json(['error' => 'Origin denied']);
3334
}
3435
}
3536

37+
3638
return $next($request);
3739
}
3840
}

0 commit comments

Comments
 (0)