nuxt-alt / auth

An alternative module to @nuxtjs/auth
https://nuxt-alt-auth.vercel.app/
MIT License
94 stars 20 forks source link

Local authroize call gets rejected because of content type "application/x-www-form-urlencoded" #104

Closed ttonyh closed 5 months ago

ttonyh commented 5 months ago

Environment


Nuxt Config

N/A

Reproduction

Call the loginWith method on the strategy.

Describe the bug

Upgrading from @nuxt-alt/auth 3.0.5 to 3.1.4 causes the auth to call a local method (in Nuxt) that calls the endpoint, which returns a 415 error of Unsupported media type application/x-www-form-urlencoded;charset=UTF-8 in request. Digging though the auth source, I noticed that there's a config named useForms that changes the content-type header. I tried to apply this option, both in the root of the config and inside of the strategy and I still get the same result.

Additional context

No response

Logs

No response

ttonyh commented 5 months ago

Here's my config if it helps:


{
    rewriteRedirects: true,
    watchLoggedIn: true,
    fullPathRedirect: true,
    redirect: {
        login: '/sign-in',
        logout: '/',
        home: '/'
    },
    stores: {
        pinia: {
            enabled: false
        },
        localStorage: {
            prefix: `${storagePrefix}auth_`
        },
        cookie: {
            prefix: `${storagePrefix}auth_`,
            options: {
                path: '/'
            }
        }
    },
    strategies: {
        local: {
            scheme: 'refresh',
            token: {
                property: 'tokenPair.access',
                type: 'Bearer',
                global: true
            },
            refreshToken: {
                property: 'tokenPair.refresh',
                data: 'refresh'
            },
            user: {
                property: 'user'
            },
            endpoints: {
                logout: false,
                login: {
                    url: `${SERVER_BASE_URL}/v1/auth/login/`,
                    method: 'post',
                    credentials: 'include'
                },
                refresh: {
                    url: `${SERVER_BASE_URL}/v1/auth/refresh/`,
                    method: 'post',
                    credentials: 'include'
                },
                user: {
                    url: `${SERVER_BASE_URL}/v1/user/`,
                    method: 'get',
                    credentials: 'include'
                }
            }
        }
    }
}
Denoder commented 5 months ago

try using @nuxt-alt/auth@beta

ttonyh commented 5 months ago

Using BETA: 3.1.5-beta.4 getting the same result.

Denoder commented 5 months ago

okay update the the beta tag again and try again. I've decoupled the request from forwarding previous headers.

ttonyh commented 5 months ago

Using version 3.1.5-beta.5 still getting same error.

Denoder commented 5 months ago

Use the http module options and enable debugging and post the output.