Page MenuHomePhorge

D4962.1775519469.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D4962.1775519469.diff

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

Mime Type
text/plain
Expires
Mon, Apr 6, 11:51 PM (5 h, 13 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18834394
Default Alt Text
D4962.1775519469.diff (1 KB)

Event Timeline