How do i redirect users to a page in my app after login using universal login with (next-js)

i wanted to redirected the user to my posts page in my app after they login using universal login how do i that with code ?

Hi @adhamdoody7813,

Thanks for reaching out to the Auth0 Community!

To redirect your users to your posts page after they have logged in, please specify the redirect URL in the redirect_uri query parameter of the /authorize request.

For example:

https://{yourDomain}/authorize?
    response_type=code&
    client_id={yourClientId}&
    redirect_uri={YOUR_POSTS_PAGE_URL}&
    scope={scope}&
    audience={apiAudience}&
    state={state}

See this documentation for more details.

Please let me know if you have any questions.

Thanks,
Rueben

i forgot to mention i am using next js @rueben.tiow

Hi @adhamdoody7813,

Thank you for your response and clarification!

Using Auth0’s Next.js SDK, there are a couple of ways:

  1. In your config.ts file, specify the baseURL

    (Reference: BaseConfig | @auth0/nextjs-auth0)
  2. In your Login Handler, specify the returnTo property in the request.

    (Reference: LoginOptions | @auth0/nextjs-auth0)

Please let me know if you have any additional questions.

Thanks,
Rueben

@rueben.tiow i can’t find the config.ts file u mentioned the only file that i have is next.config.js

Hi @adhamdoody7813,

Thank you for your reply.

If you are using the Auth0 Next.js Quickstart, there should be a .env file in which you can set the AUTH0_BASE_URL value.

With that, could you please confirm if you have a chance to locate this file and include the redirect URL in the AUTH_BASE_URL value?

For example,t his is what I see in my file:

I look forward to your update.

Thanks,
Rueben

@rueben.tiow i do have the .env file

Hi @adhamdoody7813,

Thank you for that information.

Have you gotten a chance to update the .env file’s AUTH0_BASE_URL?

See this link as a reference: auth0-nextjs-samples/Sample-01 at main · auth0-samples/auth0-nextjs-samples · GitHub

@rueben.tiow i have attempted to set the auth_0_BASE_URL with the url that i want the user to be redirected to after he logs in http:localhost:3000/PostsPage if that’s correct however when i click the login button which redirects me to the universal login page i get this

, i have updated my allowed callback urls as well

Hi @adhamdoody7813.

Thank you for the update.

I noticed in your screenshot an error where it states that there is a Callback URL mismatch.

Beneath the page, there is a Technical Details section. If you click on the link to “see details for this error” it should provide more information about the actual and expected callback URL. Afterwards, you can check your Application settings to verify if it has the callback URL.

Please let me know how it goes.

Thanks,
Rueben.

@rueben.tiow i have actually check my callback field i do have the right callbacks but for some reason i got this message

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.