-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: provide proper error when POSTing to a missing page endpoint #8714
Conversation
🦋 Changeset detectedLatest commit: 9000f87 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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!
@@ -69,23 +69,23 @@ export async function handle_action_json_request(event, options, server) { | |||
}); | |||
} | |||
} catch (e) { | |||
const error = normalize_error(e); | |||
const err = normalize_error(e); |
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.
FYI @bluwy , I think there's a Vite bug where it thinks that error
is the function imported at the top, not the const
declared here.
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.
👍 looks like @gtm-nayan got it fixed at vitejs/vite#11811
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.
Oh nice 🎉
return leaf_node.server && event.request.method !== 'GET' && event.request.method !== 'HEAD'; | ||
export function is_action_request(event) { | ||
const { method } = event.request; | ||
return method !== 'GET' && method !== 'HEAD'; |
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.
On my phone so viewing the code a few lines at a time and could be misunderstanding, but shouldn't this be checking that method is POST?
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.
Was confused by that as well, but didn't want to trigger any unwanted changes so I just kept it as is.
PUT, PATCH, DELETE don't ever reach this point but other unknown methods might, do you want to tighten it down?
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 is probably a reminiscent of old times, yes we can simplify that to just check for POST
Closes #8696
Closes #8713
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.