Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] [auth][error] UnknownAction: Cannot parse action at /api/auth/session #5783

Closed
sharifrezvani opened this issue Jan 27, 2024 · 0 comments · Fixed by #5790
Closed

[🐞] [auth][error] UnknownAction: Cannot parse action at /api/auth/session #5783

sharifrezvani opened this issue Jan 27, 2024 · 0 comments · Fixed by #5790
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@sharifrezvani
Copy link

sharifrezvani commented Jan 27, 2024

Which component is affected?

Qwik Runtime

Describe the bug

I have a project which uses auth/core and qwik-auth, after upgrading @auth/core from 0.21.0 to 0.22.0 I get this error right after my project is built,

[auth][error] UnknownAction: Cannot parse action at /api/auth/session .Read more at https://errors.authjs.dev#unknownaction
    at parseActionAndProviderId (/home/projects/qwik-starter/node_modules/@auth/core/lib/utils/web.js:122:15)
    at Module.toInternalRequest (/home/projects/qwik-starter/node_modules/@auth/core/lib/utils/web.js:52:40)
    at Module.Auth (/home/projects/qwik-starter/node_modules/@auth/core/index.js:82:53)
    at getSessionData (/home/projects/qwik-starter/node_modules/@builder.io/qwik-auth/lib/index.qwik.mjs:305:50)
    at onRequest (/home/projects/qwik-starter/node_modules/@builder.io/qwik-auth/lib/index.qwik.mjs:244:50)
    at async Object.next (/home/projects/qwik-starter/node_modules/@builder.io/qwik-city/vite/index.cjs:24850:9)
    at async runNext (/home/projects/qwik-starter/node_modules/@builder.io/qwik-city/vite/index.cjs:25095:5)
    at async eval (/home/projects/qwik-starter/node_modules/@builder.io/qwik-city/vite/index.cjs:25663:26)
1:43:04 PM [vite] Internal server error: `line` must be greater than 0 (lines start at line 1)
      at originalPositionFor$1 (/home/projects/qwik-starter/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:10341:19)
      at eval (/home/projects/qwik-starter/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50714:25)
      at eval (/home/projects/qwik-starter/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50705:21)
      at ssrRewriteStacktrace (/home/projects/qwik-starter/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50704:10)
      at ssrFixStacktrace (/home/projects/qwik-starter/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50757:24)
      at Object.ssrFixStacktrace (/home/projects/qwik-starter/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:60441:13)
      at eval (/home/projects/qwik-starter/node_modules/@builder.io/qwik-city/vite/index.cjs:25682:18)

Reproduction

https://stackblitz.com/edit/qwik-starter-96yysh?file=package.json,src%2Froutes%2Fplugin%40account.ts,.env

Steps to reproduce

  1. create a qwik project with the package.json which looking like this:
   {
 "name": "my-qwik-basic-starter",
 "description": "Demo App with Routing built-in (recommended)",
 "engines": {
   "node": ">=15.0.0"
 },
 "private": true,
 "scripts": {
   "build": "qwik build",
   "build.client": "vite build",
   "build.preview": "vite build --ssr src/entry.preview.tsx",
   "build.types": "tsc --incremental --noEmit",
   "deploy": "echo 'Run \"npm run qwik add\" to install a server adapter'",
   "dev": "vite --mode ssr",
   "dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
   "fmt": "prettier --write .",
   "fmt.check": "prettier --check .",
   "lint": "eslint \"src/**/*.ts*\"",
   "preview": "qwik build preview && vite preview --open",
   "start": "vite --open --mode ssr",
   "qwik": "qwik"
 },
 "devDependencies": {
   "@auth/core": "^0.22.0",
   "@builder.io/qwik": "^1.4.0",
   "@builder.io/qwik-auth": "~0.1.3",
   "@builder.io/qwik-city": "^1.4.0",
   "@types/eslint": "8.56.2",
   "@types/node": "^20.11.5",
   "@typescript-eslint/eslint-plugin": "6.19.1",
   "@typescript-eslint/parser": "6.19.1",
   "eslint": "8.56.0",
   "eslint-plugin-qwik": "^1.4.0",
   "prettier": "3.2.4",
   "typescript": "5.3.3",
   "undici": "6.4.0",
   "vite": "5.0.12",
   "vite-tsconfig-paths": "4.3.1"
 }
}
  1. add a file called plugin@account.ts in the routes directory of your app with the following content:
// @ts-nocheck

import { serverAuth$ } from '@builder.io/qwik-auth';
import type { Provider } from '@auth/core/providers';
import Keycloak from '@auth/core/providers/keycloak';

export const { onRequest, useAuthSession, useAuthSignin, useAuthSignout } =
  serverAuth$(({ env }) => ({
    secret: env.get('AUTH_SECRET'),
    trustHost: true,
    callbacks: {
      async session({ session, token }) {
        session.user.guid = token.sub;
        return session;
      },
    },
    providers: [
      Keycloak({
        clientId: 'Site',
        clientSecret: env.get('KEYCLOAK_CLIENT_SECRET') as string,
        issuer: env.get('KEYCLOAK_ISSUER') as string,
      }),
    ] as Provider[],
  }));
  1. npm run dev

System Info

System:
    OS: Linux 6.5 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (8) x64 AMD Ryzen 5 PRO 3500U w/ Radeon Vega Mobile Gfx
    Memory: 6.03 GB / 13.57 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.11.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.3.0 - /usr/local/bin/npm
  Browsers:
    Chromium: 120.0.6099.224

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant