solidjs-community / mediakit

A set of utilities to use with your Solid apps.
https://mediakit-taupe.vercel.app
137 stars 12 forks source link

`@solid-mediakit/auth` issue with `@auth/core` v0.35.0 (UnknownAction: Cannot parse action at /session) #100

Closed peterhirn closed 1 month ago

peterhirn commented 1 month ago

I'm not sure if this is a issue here or in @auth/core.

Using the just released v0.35.0 fails with

[auth][error] UnknownAction: Cannot parse action at /session. Read more at https://errors.authjs.dev#unknownaction

Workaround

AUTH_URL=http://localhost:3000/api/auth

Additional log spam (basePath not configured in my SolidAuthConfig)

[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
OrJDev commented 1 month ago

can you try adding:

VITE_AUTH_PATH=/api/auth
AUTH_URL=http://localhost:3000

to your .env and see if it works?

peterhirn commented 1 month ago

Unfortunately throws the same error

[auth][error] UnknownAction: Cannot parse action at /session. Read more at https://errors.authjs.dev#unknownaction
    at parseActionAndProviderId (file:///project/node_modules/.pnpm/@auth+core@0.35.0/node_modules/@auth/core/lib/utils/web.js:93:15)
    at toInternalRequest (file:///project/node_modules/.pnpm/@auth+core@0.35.0/node_modules/@auth/core/lib/utils/web.js:24:40)
    at Module.Auth (file:///project/node_modules/.pnpm/@auth+core@0.35.0/node_modules/@auth/core/index.js:67:35)
    at Module.getSession (/project/node_modules/.pnpm/@solid-mediakit+auth@2.1.2_@auth+core@0.35.0_@solidjs+meta@0.29.4_solid-js@1.8.22__@solidjs+r_f44f3uukfshh32i6kk7u4dpwiq/node_modules/@solid-mediakit/auth/index.js:211:48)
OrJDev commented 1 month ago

Well our team really didn't touch the auth package in a while (since we developed and published some more packages), therefore, it is possible that the AuthJS team changed their api, i will have to get this package bumped to the latest version, i will do it either today or tomorrow

peterhirn commented 1 month ago

Nice, thank you. This is not urgent, the workaround is good, log spam not a problem. Since auth/core is still v0.x it is basically pinned here and users have to actively force a newer version.

OrJDev commented 1 month ago

looking at their source code, you basically shouldn't have both basePath and AUTH_URL configured, this is such a useless warning and im not sure why they did it but at least we know now that its just a warning and everything should still work as expected

  try {
    const url = envObject.AUTH_URL
    if (url) {
      if (config.basePath) {
        if (!suppressBasePathWarning) {
          const logger = setLogger(config)
          logger.warn("env-url-basepath-redundant")
        }
      } else {
        config.basePath = new URL(url).pathname
      }
    }
  } catch {
    // Catching and swallowing potential URL parsing errors, we'll fall
    // back to `/auth` below.
  } finally {
    config.basePath ??= `/auth`
  }
peterhirn commented 1 month ago

Agreed. I think it would be reasonable to set suppressBasePathWarning here:

https://github.com/solidjs-community/mediakit/blob/main/packages/auth/solid/src/utils.ts#L74

see https://authjs.dev/reference/core#setenvdefaults

OrJDev commented 1 month ago

Agreed. I think it would be reasonable to set suppressBasePathWarning here:

https://github.com/solidjs-community/mediakit/blob/main/packages/auth/solid/src/utils.ts#L74

see https://authjs.dev/reference/core#setenvdefaults

Yep i saw it i just wasn't sure if i want to disable the warnings, but tbf im not sure why it even warns based on this condition so i will probably disable it for now