drunomics / nuxtjs-drupal-ce

A Nuxt module to easily connect Drupal via custom elements.
https://lupus-decoupled.org/
MIT License
22 stars 4 forks source link

Reimplement useProxy option #109

Closed TurtlBbx closed 5 months ago

TurtlBbx commented 1 year ago

useProxy: If set to dev-only and nuxt is in dev-mode, the module automatically configures /api to the Drupal backend via @nuxtjs/proxy and uses it instead of the Drupal backend, such that there are no CORS issues. Other values supported are always or false.

@nuxtjs/proxy does not support Nuxt 3. There is an open issue: https://github.com/nuxt-community/proxy-module/issues/107.

There is also https://vitejs.dev/config/server-options.html#server-proxy if we want to support only the dev-only option. If we want to support also the always option, then we need to find a suitable solution. Maybe https://github.com/wobsoriano/nuxt-proxy?

But I need feedback if this is important to support in production mode (always option) @fago?

fago commented 1 year ago

But I need feedback if this is important to support in production mode (always option) @fago?

I don't think this is important. I suppose it would have to be done manually when desired, what should not not be hard with nuxt3.

I think our module should just integrate with the existing nuxt-ecosystem and use what's there, when production-proxy is not there for nuxt3, let's not support it and build upon the vite-proxy for now. We just need to clearly document what's supported and what not.

Generally, I think we should stop doing "dev-only" as default and turn this feature off by default. We have localhost added as allowed CORS for develoment sites, so this should be good enough. Let's not do too much magic by default, but have people opt-in better

fago commented 1 year ago

Actually, we figured this is quiet helpful for authentication, since requests go via the frontend domain also, so it can be helpful with setting up cookie based authentication. so having this is a valuable option still, but it can be turned off by default.

The feature is available in nuxt3 via nitro route rules

fago commented 5 months ago

this is shipped in https://github.com/drunomics/nuxtjs-drupal-ce/releases/tag/v2.0.0-beta4