-
Notifications
You must be signed in to change notification settings - Fork 551
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
feat: implement form actions handlers #1286
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1286 +/- ##
==========================================
+ Coverage 76.73% 76.83% +0.09%
==========================================
Files 71 68 -3
Lines 7273 6829 -444
Branches 727 692 -35
==========================================
- Hits 5581 5247 -334
+ Misses 1691 1580 -111
- Partials 1 2 +1 |
96d261f
to
37263d6
Compare
1c56936
to
29b593d
Compare
bece52f
to
8786eae
Compare
1a635f0
to
bd522e9
Compare
edeed46
to
7fbb874
Compare
@pi0 This is ready for review, I followed the approach that you suggested with a separated router for form actions |
7fbb874
to
5604efd
Compare
5604efd
to
efcb554
Compare
efcb554
to
dabd367
Compare
With the upstream fix in h3 (unjs/h3#461), we can actually register form action routes with their method and no additional configuration and they are expected to work nicely with the default renderer catch-all route. |
Thanks @pi0, I can confirm that everything is working smoothly. |
π Linked issue
nuxt/nuxt#20649
nuxt/nuxt#20852
https://github.com/Hebilicious/form-actions-nuxt
β Type of change
π Description
This PR adds an experimental features that allows Nitro to supports fallback routes.
This is useful to register a post handler alongside the nuxt renderer.
nitro.config.handlers.push({ route: "/hello-world", handler: "~/actions/hello-world.ts", formAction: true })
Nitro will send an error if there's a form action handler but no renderer has been specified.
When hitting /hello-world with a post request, the registered handler will be used.
But when hitting /hello-world with a get request, the renderer will be used.
Something to potentially do in the future would be to add the action directory to the nitro scanners.
π Checklist