nuxt-auth-utils icon indicating copy to clipboard operation
nuxt-auth-utils copied to clipboard

Request for Custom Session Endpoint Support in nuxt-auth-utils

Open victorfds opened this issue 7 months ago • 3 comments

I am currently working on a use case where I need to customise the endpoint used for fetching the session. The default endpoint (/api/_auth/session) does not meet my requirements, and I would like to change it to a custom endpoint, such as /custom-api/_auth/session.

For context, I am using Client-Side Rendering (CSR) and a proxy intercepts all requests to the /api path and redirects them to the appropriate backend, logging in doesn't work in this case. After checking carefully, it appears that the module currently does not offer the flexibility to support this customization.

Allowing the configuration of a custom session endpoint would greatly enhance the versatility of the module, making it more adaptable to various backend setups or API configurations.

Would it be possible to introduce an option within the module to specify a custom session endpoint?

Thank you for considering this request. Please do not hesitate to contact me should you require any further details or if I can assist with testing or implementation.

Kind regards,
Victor Ferreira da Silva

victorfds avatar Apr 10 '25 14:04 victorfds

Hi @victorfds

Adding new option will bring more complexity.

Though, I see your problem and I believe that Nuxt Auth Utils should not pollute the /api namespace, but instead be on /.nuxt-auth-utils/session

atinux avatar May 07 '25 13:05 atinux

Moving the session endpoint to /.nuxt-auth-utils/session would prevent pollution of the /api namespace, but it would still be helpful to make the endpoint path configurable. We are using nuxt in a reverse proxy setup where we only control a subpath of the root domain: example.com/our-nuxt-app/. So we'll never see requests to /api or /.nuxt-auth-utils. Ideally, we'd be able to add a module setting like sessionRoute: '/our-nuxt-app/api/_auth/session'.

@atinux - would you be open to a PR to add that module option?

joelfillmore avatar Oct 09 '25 17:10 joelfillmore

I've also run into this issue. I don't think using /api/ to proxy requests to a different backend is all that uncommon. I'm now considering changing a few hundred ingress path definitions from /api(/|$)(.*) to /api(/(?!_auth(/|$))|$)(.*) to facilitate this, but I'd much prefer not to if there was another solution, such as a configuration option or at least a more uncommon default path.

MarkoTukiainen avatar Nov 12 '25 14:11 MarkoTukiainen