Hebilicious/form-actions-nuxt

Dynamic params require h3's `:param` syntax and not nuxt/nitro's `[param]` syntax

Opened this issue · 0 comments

Environment

------------------------------
- Operating System: Linux
- Node Version:     v20.11.0
- Nuxt Version:     3.9.1
- CLI Version:      3.10.0
- Nitro Version:    2.8.1
- Package Manager:  pnpm@8.14.3
- Builder:          -
- User Config:      site, schemaOrg, devtools, components, modules, devServer, vite, routeRules, runtimeConfig, image, fontMetrics, googleFonts, sourcemap, hooks, sitemap, imports, build, robots
- Runtime Modules:  @nuxt/devtools@1.0.6, @nuxt/image@1.1.0, @nuxtjs/tailwindcss@6.10.4, @nuxtjs/fontaine@0.4.1, @nuxtjs/google-fonts@3.1.3, nuxt-icon@0.5.0, @nuxtjs/sitemap@5.0.5, nuxt-schema-org@3.3.3, nuxt-site-config@2.2.8, nuxt-simple-robots@4.0.0-rc.13, @hebilicious/form-actions-nuxt@0.3.0
- Build Modules:    -
------------------------------

Reproduction

https://github.com/drevantonder/form-actions-nuxt-dynamic-param-repro

  1. pnpm i
  2. pnpm run dev
  3. Open up in browser
  4. Try "Nuxt Param" page (/param/nuxt-param)... Doesn't work.
  5. Try "H3 Param" page (/param/h3-param)... It works.

Describe the bug

It may not necessarily be a bug, but it is confusing due to the lacking documentation.

When trying to set up a form action for a Nuxt page with a dynamic parameter (e.g. pages/[param]/nuxt-param.vue) creating an action matching the Nuxt path (e.g. server/actions/[param]/nuxt-param.vue) does not work.

Rather, after digging through .nuxt/dev/index.js, I could determine that it was h3/radix underneath the hood that the path needed to match not Nuxt. So to match a path with a dynamic parameter, the :param syntax needed to be used rather than [param].

Would be good to either support the same syntax as the pages, server/routes and server/api folders, or document the difference.

Additional context

No response

Logs

No response