logto-io / logto

🧑‍🚀 The better identity infrastructure for developers and the open-source alternative to Auth0.
https://logto.io
Mozilla Public License 2.0
8.94k stars 446 forks source link

bug: Getting invalid_redirect_uri on local docker instance #6758

Closed raminious closed 2 weeks ago

raminious commented 2 weeks ago

Describe the bug

I get this error when I'm trying to connect a local React app to a local Logto instance running on Docker

{"code":"oidc.invalid_redirect_uri","message":"`redirect_uri` did not match any of the client's registered `redirect_uris`.","error":"invalid_redirect_uri","error_description":"redirect_uri did not match any of the client's registered redirect_uris","state":"1PRuqSahxd8XK-d6guzqUV9v-9LkQOaCbwFrbBU2aj_0pY0Kunc5ujKkOKMocPHNcPkvjYlY-cOsFGxb7b-yQg","iss":"http://localhost:3001/oidc"}

Expected behavior

It should display login screen

How to reproduce?

run Logto and create an app:

curl -fsSL https://raw.githubusercontent.com/logto-io/logto/HEAD/docker-compose.yml | \
docker compose -p logto -f - up
image

Create a simple react app:

const config: LogtoConfig = {
  endpoint: 'http://localhost:3001',
  appId: '****',
}

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <LogtoProvider config={config}>
      <App />
    </LogtoProvider>
  </React.StrictMode>,
)
import { useLogto } from "@logto/react"

export default function App() {
  const { signIn, signOut, isAuthenticated } = useLogto()

  return (
    <div>
      {
        isAuthenticated ? (
          <button onClick={() => signOut()}>Sign Out</button>
        ) : (
          <button onClick={() => signIn('http://localhost:5170/callback')}>Sign In</button>
        )
      }
    </div>
  )
}

Click on SingIn app.

Context

Screenshots

image image
raminious commented 2 weeks ago

sorry it was a misconfiguration