-
-
Notifications
You must be signed in to change notification settings - Fork 229
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 grapher 404 page #3970
Fix grapher 404 page #3970
Conversation
Quick links (staging server):
Login:
SVG tester:Number of differences (default views): 0 ✅ Edited: 2024-09-17 15:06:22 UTC |
This is an alternative fix for the one reverted in 24f6288.
35c6bb9
to
53224b7
Compare
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.
Tested locally with grapher routes that should 404 and grapher routes that should redirect and they all worked 👍
@@ -146,7 +102,7 @@ async function handleHtmlPageRequest( | |||
const grapherPageResp = await env.ASSETS.fetch(url, { redirect: "manual" }) | |||
|
|||
if (grapherPageResp.status === 404) { | |||
throw new StatusError(404) | |||
return handlePageNotFound(env, grapherPageResp) |
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.
One thing I noticed while tinkering with the code, the For local testing
commented-out code block above here could be updated to call fetch
from env.ASSETS
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 think a comment here would be useful that mentions that by passing in the grapherPageResp as the fallback we get a 404 status code but also an HTML 404 page. Otherwise this subtle detail might be lost in bigger refactorings in the future.
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.
Added a comment about grapherPageResp
.
commented-out code block above here could be updated to call
fetch
fromenv.ASSETS
Even if it works, I think it makes sense to leave it to a normal fetch, since we are not fetching from the assets (semantically), we are fetching from the internet.
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 checked some of the new routes as well and it all looks good from my side too - thanks!
@@ -146,7 +102,7 @@ async function handleHtmlPageRequest( | |||
const grapherPageResp = await env.ASSETS.fetch(url, { redirect: "manual" }) | |||
|
|||
if (grapherPageResp.status === 404) { | |||
throw new StatusError(404) | |||
return handlePageNotFound(env, grapherPageResp) |
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 think a comment here would be useful that mentions that by passing in the grapherPageResp as the fallback we get a 404 status code but also an HTML 404 page. Otherwise this subtle detail might be lost in bigger refactorings in the future.
This is an alternative fix for the one reverted in 24f6288.