Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find custom 404 page with trailing slash #7616

Closed
1 task
HomWang opened this issue Jul 10, 2023 · 4 comments
Closed
1 task

Unable to find custom 404 page with trailing slash #7616

HomWang opened this issue Jul 10, 2023 · 4 comments
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: error pages Related to 404 and 500 handling (scope)

Comments

@HomWang
Copy link

HomWang commented Jul 10, 2023

What version of astro are you using?

v2.8.0

Are you using an SSR adapter? If so, which one?

Node

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

When output: "hybrid", accessing a non-existent page, the custom 404 page cannot be found.
Automatically add '/' after the URL
Step:
1.npm run build
2.HOST=0.0.0.0 PORT=3000 node dist/server/entry.mjs
3.localhost:3000/en/test/asd
4.Custom 404 page not found

What's the expected result?

  1. Find the custom 404 page
  2. Remove the trailing slash

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-nhc9gb-malcwc?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re natemoo-re self-assigned this Jul 11, 2023
@HomWang
Copy link
Author

HomWang commented Jul 12, 2023

I have a question, I don't know how to implement it.
[lang]/page/[id].astro
Expect:

  1. url: /en/page/10
  2. url: /page/10
    I don't know how to achieve it

About another question
Use output: "hybrid"
The route will prioritize matching SSG before matching SSR.
Can I set it to match SSR first and then match SSG, because in actual website visits, I need a dynamic route. If the SSR application crashes, I can use SSG

@natemoo-re
Copy link
Member

I am looking into this and can see that we aren't handling 404 pages properly in hybrid mode. Working on a fix.

  • Trailing slash behavior can be configured with the trailingSlash option
  • Please open new issues for other bugs and visit our Discord for support questions.

@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Jul 14, 2023
@HomWang
Copy link
Author

HomWang commented Jul 17, 2023

I am looking into this and can see that we aren't handling 404 pages properly in hybrid mode. Working on a fix.

  • Trailing slash behavior can be configured with the trailingSlash option
  • Please open new issues for other bugs and visit our Discord for support questions.

TrailingSlash can only be used in development. In output: "hybrid" and SSG mode, it will automatically add at the end /

@natemoo-re natemoo-re added the feat: error pages Related to 404 and 500 handling (scope) label Aug 16, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Aug 18, 2023

Fixed in #8070 (astro v2.10.10+)
image

@lilnasy lilnasy closed this as completed Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: error pages Related to 404 and 500 handling (scope)
Projects
None yet
Development

No branches or pull requests

3 participants