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

fix: provide proper error when POSTing to a missing page endpoint #8714

Merged
merged 5 commits into from
Jan 25, 2023

Conversation

gtm-nayan
Copy link
Contributor

Closes #8696
Closes #8713

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2023

🦋 Changeset detected

Latest commit: 9000f87

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dummdidumm dummdidumm merged commit 4df53c7 into master Jan 25, 2023
@dummdidumm dummdidumm deleted the missing-actions branch January 25, 2023 08:41
@github-actions github-actions bot mentioned this pull request Jan 25, 2023
@@ -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);
Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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';
Copy link
Member

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?

Copy link
Contributor Author

@gtm-nayan gtm-nayan Jan 25, 2023

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?

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cryptic error when no route and using form enhance POSTing to a page without actions should result in a 405
4 participants