From a7ef6321a5224e0d494f1e1a0653dec676caf9a0 Mon Sep 17 00:00:00 2001 From: Venkata Chandra Sekhar Nainala Date: Tue, 23 Jan 2024 15:33:30 +0100 Subject: [PATCH] fix: resolves #1048 --- app/Http/Controllers/CitationController.php | 2 +- app/Http/Middleware/HandleInertiaRequests.php | 2 +- app/Http/Middleware/XFrameOptions.php | 10 ++++++++-- ...1_22_160016_remove_abstract_from_citation_table.php | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/CitationController.php b/app/Http/Controllers/CitationController.php index e845a3e6..974f8963 100644 --- a/app/Http/Controllers/CitationController.php +++ b/app/Http/Controllers/CitationController.php @@ -88,4 +88,4 @@ public function destroy(Request $request, UpdateProject $updater, Project $proje return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('success', 'Citation deleted successfully'); } -} \ No newline at end of file +} diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index a751dec0..acf4ebef 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -83,4 +83,4 @@ public function share(Request $request) 'DATACITE_API' => env('DATACITE_API'), ]); } -} \ No newline at end of file +} diff --git a/app/Http/Middleware/XFrameOptions.php b/app/Http/Middleware/XFrameOptions.php index a60f2561..f957a50e 100644 --- a/app/Http/Middleware/XFrameOptions.php +++ b/app/Http/Middleware/XFrameOptions.php @@ -20,9 +20,15 @@ public function handle(Request $request, Closure $next): Response if ($request->route()->getName() == 'embed') { return $response->header('Content-Security-Policy', 'frame-src data: blob: *'); } else { - $xframeOptions = 'SAMEORIGIN'; - return $response->header('X-Frame-Options', $xframeOptions); + if ($response instanceof \Illuminate\Http\Response) { + $xframeOptions = 'SAMEORIGIN'; + + return $response->header('X-Frame-Options', $xframeOptions); + } else { + return $response; + } + } } } diff --git a/database/migrations/2024_01_22_160016_remove_abstract_from_citation_table.php b/database/migrations/2024_01_22_160016_remove_abstract_from_citation_table.php index d1544cf6..d7b82aab 100644 --- a/database/migrations/2024_01_22_160016_remove_abstract_from_citation_table.php +++ b/database/migrations/2024_01_22_160016_remove_abstract_from_citation_table.php @@ -25,4 +25,4 @@ public function down(): void $table->string('abstract')->nullable(); }); } -}; \ No newline at end of file +};