-
Notifications
You must be signed in to change notification settings - Fork 149
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
[Theme] Fix 401 and 405 for certain routes in local dev #5329
base: main
Are you sure you want to change the base?
Conversation
Coverage report
Show files with reduced coverage 🔻
Test suite run success2044 tests passing in 913 suites. Report generated by 🧪jest coverage report action from 69d37db |
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.
Thank you for this PR, @frandiox! I've left only one minor comment about the html
module :)
8e3f962
to
f22d234
Compare
@karreiro To fix the problems I had earlier, I've refactored our proxy and render logic to use the native Generally, I've tried to move away from h3 v1 utilities as much as possible. Turns out they support returning Responses in v1 as well, and I think it's their default in v2. |
/snapit |
🫰✨ Thanks @frandiox! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/[email protected]
|
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.
Thank you, @frandiox! Excellent changes — we're going to have much more control over proxy requests with this change! 🚀
I've 🎩ed the proxy changes on shopify theme dev
and shopify app dev
🔥
I've left two minor comments about:
- Presenting the request IDs in some scenarios.
- Preventing a warning from rendering in the scenario mentioned.
With those two minor changes applied, I believe this PR will be ready to be shipped!
const status = error.statusCode ?? 502 | ||
const statusText = error.statusMessage ?? 'Bad Gateway' | ||
|
||
let headline = `Failed to render storefront with status ${status} (${statusText}).` |
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.
We're getting a 404 here when running the development server via shopify app dev
. I've raised an issue for supporting the final fix for this.
While we don't have that fixed, can we prevent the warning from being rendered here when the app_block_id
query parameter is passed? (Alternatively, instead of preventing it, we could still render the warning here in the verbose output in that context.)
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 believe you mean the warning in hot-reload/server instead of this one, right?
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.
Precisely, I believe that's very nice to have, but we may also apply that fix in another PR, as it transcends a bit the scope of this one.
946e9e4
to
8cbcec8
Compare
WHY are these changes introduced?
[HOLD] -- This currently fails when the proxy logic gets a 401 or similar because H3 has already sent headers/status and we can't overwrite them.Fixes #5103
WHAT is this pull request doing?
Certain routes can't be rendered by SFR (e.g. app routes) and we must proxy them instead. We don't know before hand all of these routes, so this PR is adding a fallback: if a rendering fails with 4xx (the observed status errors for this situation), we try to proxy it. If the proxy doesn't work, we forward the original render error.
How to test your changes?
/account/logout
with--verbose
. It should show that render failed and proxying worked./not-found-path
. It should return the rendering error after trying the proxy (see logs).Post-release steps
Measuring impact
How do we know this change was effective? Please choose one:
Checklist