Issue
export const routes: Routes = [
{ path: 'foo.bar', component: ListComponent },
{ path: 'foobar', component: ListComponent },
example.com/foobar
works well and example.com/foo.bar
return 404
It works fine in the production environment but only appears on the local development page when using ng serve
. This makes it a bit challenging for me to debug specific url parameters.
Regarding this 404 error, even if the page I'm trying to access isn't configured in the routes
, it should redirect to the default **
or /
destination instead of going straight to a 404.
curl -i http://127.0.0.1:4200/foo.bar
HTTP/1.1 404 Not Found
Access-Control-Allow-Origin: *
Date: Thu, 11 Jan 2024 02:52:11 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 0
curl -i http://127.0.0.1:4200/foobar
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: text/html
Cache-Control: no-cache
Date: Thu, 11 Jan 2024 02:52:13 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 891
<!doctype html>
<html lang="en">
<head>
<script type="module" src="/openai/@vite/client"></script>
...
Solution
Angular CLI 17 uses new application builder by default.
That means that you're running your code with combination of esbuild and vite.
It was a known issue with vite and should be fixed starting with @angular/cli@17.1.0-next.0
.
Related issues:
- https://github.com/angular/angular-cli/issues/26320#issuecomment-1805619487
- https://github.com/angular/angular-cli/issues/26551
Answered By - yurzui
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.