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
fix(web): @nrwl/web:file-server throws 404 after refresh #9839
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nrwl/nx-dev/GGsGfJdiq4ZaNi7ZB9SUE1Tt9RKk [Deployment for 132cca1 canceled] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
|
||
if (options.spa) { | ||
const src = join(outputPath, 'index.html'); | ||
const dst = join(outputPath, '494.html'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be 404.html, rather than 494.html
}, | ||
"spa": { | ||
"type": "boolean", | ||
"description": "Serve `SPA` app.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably detail the differences, rather than just reiterating the option name. Something like: Redirect not-found errors to index.html (useful for SPAs)
.
@imhuytq There are some conflicts now as well, as soon as those are addressed and the comments taken care of this should be ready to go. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @AgentEnder , Thanks for your review. Please check my updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good now, I'll rebase it to remove the husky changes and then work on getting it merged. Thanks for the contribution 🎉
.husky/_/husky.sh
Outdated
#!/bin/sh | ||
if [ -z "$husky_skip_init" ]; then | ||
debug () { | ||
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1" | ||
} | ||
|
||
readonly hook_name="$(basename "$0")" | ||
debug "starting $hook_name..." | ||
|
||
if [ "$HUSKY" = "0" ]; then | ||
debug "HUSKY env variable is set to 0, skipping hook" | ||
exit 0 | ||
fi | ||
|
||
if [ -f ~/.huskyrc ]; then | ||
debug "sourcing ~/.huskyrc" | ||
. ~/.huskyrc | ||
fi | ||
|
||
export readonly husky_skip_init=1 | ||
sh -e "$0" "$@" | ||
exitCode="$?" | ||
|
||
if [ $exitCode != 0 ]; then | ||
echo "husky - $hook_name hook exited with code $exitCode (error)" | ||
exit $exitCode | ||
fi | ||
|
||
exit 0 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be in this PR 🤔
fix(web): add `spa` option fix(web): delete the 404.html file after shutting down the server docs(web): update docs
Is anyone else still getting 404s on browser refresh, even with "spa": true in the serve options? |
@joewIST Yes I am still getting 404s when my url contains query parameters like so /home/123?snack=cake |
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
As reported in #5118, using @nrwl/web:file-server will get a 404 code on browser refresh for any route other than the root.
Current Behavior
Expected Behavior
Added
spa
option to allow handling of routes other than root.Related Issue(s)
Fixes #5118