Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117918983
D4962.1775421282.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D4962.1775421282.diff
View Options
diff --git a/src/app/Utils.php b/src/app/Utils.php
--- a/src/app/Utils.php
+++ b/src/app/Utils.php
@@ -91,9 +91,10 @@
*/
public static function defaultView()
{
- // Return 404 for requests to the API end-points that do not exist
- if (strpos(request()->path(), 'api/') === 0) {
- return \App\Http\Controllers\Controller::errorResponse(404);
+ // Return standard empty 404 response for non-existing resources and API routes
+ // TODO: Is there a better way? we'd need access to the vue-router routes here.
+ if (preg_match('~^(api|themes|js|vendor)/~', request()->path())) {
+ return response('', 404);
}
$env = self::uiEnv();
diff --git a/src/tests/Unit/UtilsTest.php b/src/tests/Unit/UtilsTest.php
--- a/src/tests/Unit/UtilsTest.php
+++ b/src/tests/Unit/UtilsTest.php
@@ -48,6 +48,22 @@
\App\IP6Net::where('net_number', inet_pton('2001:db8::ff00:42:0'))->delete();
}
+ /**
+ * Test for Utils::defaultView()
+ */
+ public function testDefaultView(): void
+ {
+ // Non existing resources or api routes
+ $this->get('js/test.js')->assertNotFound()->assertContent('');
+ $this->get('vendor/test.js')->assertNotFound()->assertContent('');
+ $this->get('themes/unknown/app.css')->assertNotFound()->assertContent('');
+ $this->get('api/unknown')->assertNotFound()->assertContent('');
+
+ // Expect a view
+ $this->get('dashboard')->assertOk()->assertViewIs('root')->assertViewHas('env');
+ $this->get('unknown')->assertOk()->assertViewIs('root')->assertViewHas('env');
+ }
+
/**
* Test for Utils::emailToLower()
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 8:34 PM (1 d, 2 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18834394
Default Alt Text
D4962.1775421282.diff (1 KB)
Attached To
Mode
D4962: Return 404 on non-existing resources
Attached
Detach File
Event Timeline