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

Fallback handler to requests outside of baseURL #2980

Open
pi0 opened this issue Jan 8, 2025 · 0 comments
Open

Fallback handler to requests outside of baseURL #2980

pi0 opened this issue Jan 8, 2025 · 0 comments
Labels
discussion dx enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented Jan 8, 2025

When a custom baseURL is set, it is expected that all routes (and static assets) will be prefixed with {baseURL}/ so one should go to https://<addr>/{baseURL}.

If a request hits https://<addr>/* outside of {baseURL}, nitro renders a 404 because there is no route.

#2713 proposed a DX improvement to auto redirect /* to /{baseURL}* (only in dev) however it causes issues (#2881) as there are valid cases that a middleware or proxy route rule might actually need to handle this fallback.

In summary: This a nice DX but has downside of limiting some advanced cases and also potentially more mismatch behavior between dev and prod runtime behavior.

I am thinking of some progressive steps to handle:

  • Improve dev error to show a hint that tells users it is 404 but hey, you might want need to go to this link.
  • Add an opt-in option to enable baseURL redirect (in two modes: fallback|enforce)
    • we should keep it opt-in for v2, we might enable by default for 3.0 however I'm not sure if trade-off worth it (if we do, we need clear docs about behavior and why/how opt-out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion dx enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant