Skip to content

state is interstitial, reason: cross-origin-referrer #1566

@gerald-lbn

Description

@gerald-lbn

Package + Version

  • @clerk/nextjs (4.23.2)

Dependencies + versions

{  
  "dependencies": {
    "@clerk/nextjs": "^4.23.2",
    "@prisma/client": "^5.0.0",
    "@t3-oss/env-nextjs": "^0.3.1",
    "@tanstack/react-query": "^4.29.7",
    "@trpc/client": "^10.26.0",
    "@trpc/next": "^10.26.0",
    "@trpc/react-query": "^10.26.0",
    "@trpc/server": "^10.26.0",
    "next": "^13.4.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "superjson": "1.12.2",
    "zod": "^3.21.4"
  },
  "devDependencies": {
    "@types/eslint": "^8.37.0",
    "@types/node": "^18.16.0",
    "@types/prettier": "^2.7.2",
    "@types/react": "^18.2.6",
    "@types/react-dom": "^18.2.4",
    "@typescript-eslint/eslint-plugin": "6.0.0",
    "@typescript-eslint/parser": "6.0.0",
    "autoprefixer": "^10.4.14",
    "eslint": "^8.40.0",
    "eslint-config-next": "^13.4.2",
    "postcss": "^8.4.21",
    "prettier": "^2.8.8",
    "prettier-plugin-tailwindcss": "^0.2.8",
    "prisma": "^5.0.0",
    "tailwindcss": "^3.3.0",
    "typescript": "^5.0.4"
  }
}

Browser/OS

  • Firefox 115.0.02 (64 bits)
  • Node 18.17.0

Description

I am deploying an app with docker, a proxy and nextjs (standalone) using create-t3-app. Once I logged in, the page keeps refreshing indefinitely.
Here are the logs when I set debug to true in the middleware.ts file

le-qcm  | Clerk debug start :: authMiddleware
le-qcm  | -- URL debug, {
le-qcm  |   "url": "http://36f2bef4ae24:3000/app",
le-qcm  |   "method": "GET",
le-qcm  |   "headers": "{\"accept\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\",\"accept-language\":\"en-US,en;q=0.5\",\"connection\":\"close\",\"cookie\":\"__clerk_db_jwt=SECRET; __client_uat=1691507470; __session=SECRET\",\"dnt\":\"1\",\"host\":\"192.168.X.X:3000\",\"referer\":\"https://quizz.insat.fr/app\",\"sec-fetch-dest\":\"document\",\"sec-fetch-mode\":\"navigate\",\"sec-fetch-site\":\"same-origin\",\"upgrade-insecure-requests\":\"1\",\"user-agent\":\"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0\",\"x-forwarded-for\":\"X.X.X.X,::ffff:192.168.X.X\",\"x-forwarded-host\":\"quizz.insat.fr\",\"x-forwarded-port\":\"3000\",\"x-forwarded-proto\":\"http\",\"x-forwarded-server\":\"quizz.insat.fr\",\"x-invoke-path\":\"\",\"x-invoke-query\":\"\",\"x-middleware-invoke\":\"1\"}",
le-qcm  |   "nextUrl": "http://36f2bef4ae24:3000/app",
le-qcm  |   "clerkUrl": "http://quizz.insat.fr:3000/app"
le-qcm  | }
le-qcm  | -- Options debug, {
le-qcm  |   "debug": true,
le-qcm  |   "beforeAuth": false,
le-qcm  |   "afterAuth": true
le-qcm  | }
le-qcm  | -- authenticateRequest state is interstitial, {
le-qcm  |   "status": "interstitial",
le-qcm  |   "reason": "cross-origin-referrer",
le-qcm  |   "message": "",
le-qcm  |   "frontendApi": "precious-hookworm-55.clerk.accounts.dev",
le-qcm  |   "publishableKey": "pk_test_SECRET",
le-qcm  |   "isSatellite": false,
le-qcm  |   "domain": "",
le-qcm  |   "proxyUrl": "",
le-qcm  |   "signInUrl": "",
le-qcm  |   "isSignedIn": false,
le-qcm  |   "isInterstitial": true,
le-qcm  |   "isUnknown": false
le-qcm  | }

I was redirected to http://36f2bef4ae24:3000/app but I set CLERK_TRUST_HOST to true and the problem was fixed

If I close the tab and reopen it:

  • the app does not refresh indefinitely but all requests to my db have 401 Unauthorized.
  • I can see my profile picture, username and email with <UserButton />

At first glance, this might be related to #1436, but I synced the server's clock.

Note: I don't have this issue when I run it in my computer

Replicate the issue

  • Clone Shinyhero36/minimal-t3-clerk (a minimal repo to replicate the issue)
  • Copy .env.example to .env and set the env vars
  • Run docker compose -f docker-compose.prod.yml build
  • Run docker compose -f docker-compose.prod.yml up
  • Open http://localhost:3000, click on View app and log in

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions