`prepPKCERedirectURL`drops `//` from custom scheme URIs, corrupting PKCE auth code on iOS (`%23`)

Open
#2,423 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ios, javascript, react-native

Research direction

Trace prepPKCERedirectURL through the PKCE redirect flow, starting with the myapp:// reproduction and comparing it with makeRedirectUri() and WebBrowser.openAuthSessionAsync. Confirm completion when result.url preserves myapp://?code=CODE without the trailing %23 and exchangeCodeForSession no longer reports “No valid flow state found”.

Written by the indexing model from the issue text.

Description

bug

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When using PKCE OAuth from on iOS with a custom URL scheme that has no path (ex. myapp://), the redirect URL returned to the app contains a corrupted auth code a trailing %23 (URL-encoded #). This causes exchangeCode ForSession to fail with "No valid flow state found".

To Reproduce

  1. Create an Expo React Native app targeting iOS
  2. Use makeRedirectUri() with no arguments → returns myapp://
  3. Call supabase.auth.signInWithOAuth({ provider: 'google', options: { redirectTo: 'myapp://', skipBrowserRedirect: true } })
  4. Open the auth URL with WebBrowser.openAuthSessionAsync
  5. Complete Google sign-in
  6. Observe result.url contains myapp:?code=CODE%23 instead of myapp://?code=CODE
  7. exchangeCodeForSession fails with "No valid flow state found"

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

Add any other context about the problem here.

Dominant language
Go
Stars
2.6k
Forks
764
Avg merge
5d 3h
Merged PRs (30d)
39

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/auth

All issues in supabase/auth

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.