Login react.js relative path

Hello all. I am new to Auth0 so my question might look trivial.

I tried to use Auth0 for my react.js application and here is my code for redirect-url:

export const redirectAuth0URL = { ${window.location.href}dashboard}`

in my index.js:
<Auth0Provider redirectUri={redirectAuth0URL} />

So the


is : “http://localhost:3000/dashboard”. However, it cannot redirect me to dashboard and kind of throws an error.

Suprisingly, if I change the code above the below, it works:
export const redirectAuth0URL = window.location.href + "dashboard"

I wonder what the issue is with using template literal.

Hi @Ehsan-Home,

Welcome to the Community!

I think the markdown formatting may have gotten a little messed up.

Is the code:

export const redirectAuth0URL = `{${window.location.href}dashboard}`

Have you tried exporting the variable without the curly brackets?

export const redirectAuth0URL = `${window.location.href}dashboard`
1 Like

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