Skip to content
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

proposal: Add onRedirect hook (for supporting nuxt-i18n routing) #722

Open
5 tasks
kevindaizj opened this issue Mar 31, 2024 · 8 comments
Open
5 tasks

proposal: Add onRedirect hook (for supporting nuxt-i18n routing) #722

kevindaizj opened this issue Mar 31, 2024 · 8 comments
Assignees
Labels
enhancement An improvement that needs to be added rfc Request for Comments: Needs discussion

Comments

@kevindaizj
Copy link

Describe the feature

Implement similar functionality of Nuxt 2 nuxt-auth module: Feature

How would you implement this?

No response

Additional information

  • Would you be willing to help implement this feature?

Provider

  • AuthJS
  • Local
  • Refresh
  • New Provider
@kevindaizj kevindaizj added enhancement An improvement that needs to be added pending An issue waiting for triage labels Mar 31, 2024
@kevindaizj kevindaizj changed the title proposal: Add onRedirect hook (for supporting nuxt-i18n) proposal: Add onRedirect hook (for supporting nuxt-i18n) Mar 31, 2024
@kevindaizj kevindaizj changed the title proposal: Add onRedirect hook (for supporting nuxt-i18n) proposal: Add onRedirect hook (for supporting nuxt-i18n routing) Mar 31, 2024
@mario27
Copy link

mario27 commented Apr 11, 2024

Totally agree with you, it's a necessary feature

@skmd87
Copy link

skmd87 commented May 14, 2024

this is much needed

@zoey-kaiser
Copy link
Member

I really like this idea! Do you have any more context you could provide to this? Then I would look into beginning to work on this feature (unless you want to take a crack at it 😊)

@zoey-kaiser zoey-kaiser added rfc Request for Comments: Needs discussion and removed pending An issue waiting for triage labels Jun 27, 2024
@mrleblanc101
Copy link

mrleblanc101 commented Sep 25, 2024

Could this be achieved with a custom middleware/auth.global.ts currently while waiting for this feature to be implemented ?
I tried copy-pasting the current middleware and then modifying it, but it reference too many other functions that I couldn't find how to import once inside my app.

@mrleblanc101
Copy link

Ah, I guess not.
We don't just need to translate the guarded routes, but also the routes passed to the provider.

@zoey-kaiser
Copy link
Member

Hi @mrleblanc101 👋

This feature is already supported by the authjs provider using the redirect callback. Have a look at the docs here: https://next-auth.js.org/configuration/callbacks#redirect-callback

Inside your NuxtAuthHandler you receive the url and baseUrl, can then modify the redirect URL and return the internalized URL! For the local provider, we will need to adapt the implementation, but maybe this already covers your use case!

@mrleblanc101
Copy link

@zoey-kaiser Thanks, but I'm not sure I understand how to make it work.
To change locale on the server-side, I need to know the user locale, I just need to get it from the cookie.
But to get the value of the i18n_redirected cookie using h3 getCookie(event, "i18n_redirected");, I need access to the h3 event from the request.

@mrleblanc101
Copy link

mrleblanc101 commented Oct 3, 2024

Also, if I want keycloak locale to match my application locale, I need to pass an additional param called ?ui_locale=fr.
How would I do this ?
@nuxtjs/auth-next had an additionalParams key in the signIn method second argument just for this:
https://auth.nuxtjs.org/schemes/openIDConnect#:~:text=Additional%20arguments%20can%20be%20passed%20through%20to%20the%20OpenID%20Connect%20provider%20using%20the%20params%20key%20of%20the%20second%20argument%3A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement that needs to be added rfc Request for Comments: Needs discussion
Projects
None yet
Development

No branches or pull requests

6 participants