Hebilicious / form-actions-nuxt

Nuxt Module that implements Form Actions
https://form-actions-nuxt.pages.dev/
MIT License
126 stars 7 forks source link

Does not work with Nuxt Layers setup #84

Open maoberlehner opened 1 year ago

maoberlehner commented 1 year ago

Environment

Reproduction

https://stackblitz.com/edit/nuxt-starter-vdvjhb?file=nuxt.config.ts

Describe the bug

When using the module inside of a Nuxt Layer (https://nuxt.com/docs/getting-started/layers) the server action does not work.

In the reproduction above, we have a root application extending another application inside my-layer. my-layer uses the module. But when opening the /login page and submitting the form, nothing happens.

Additional context

No response

Logs

No response

Hebilicious commented 1 year ago

Hi @maoberlehner, thanks for using this module and opening this issue. I have not tested it with layers, and unfortunately it seems we need some layer specific logic within the module to handle this use case. I will investigate it as soon as I have time, and see how we can make this work.

I suspect that here https://github.com/Hebilicious/form-actions-nuxt/blob/a874e82dccce61d66fba66aa79d6987c7616830b/packages/form-actions-nuxt/src/module.ts#L89

we should try to detect actions that are located within layers.

@danielroe tagging you here, could we introduce a kit utility that resolves a path for all layers, or something to help in this scenario (https://nuxt.com/docs/guide/going-further/layers#multi-layer-support-for-nuxt-modules maybe) ? Or should modules that reads the filesystem handle layers separately ?