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

baseURL is being ignored #749

Closed
phuze opened this issue Apr 30, 2024 · 1 comment
Closed

baseURL is being ignored #749

phuze opened this issue Apr 30, 2024 · 1 comment
Labels
bug A bug that needs to be resolved pending

Comments

@phuze
Copy link

phuze commented Apr 30, 2024

Environment

  • Operating System: Windows_NT
  • Node Version: v20.11.1
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Package Manager: [email protected]
  • User Config: devtools, devServer, modules, auth, runtimeConfig, publicRuntimeConfig
  • Runtime Modules: @sidebase/[email protected]

Reproduction

-na-

Describe the bug

Issue:

Local auth provider is ignoring the baseURL. I have configured this every possible way, yet nothing seems to have any effect.

Error:

POST http://10.0.0.110/api/auth/api/auth/login 404 (Page not found: /api/auth/api/auth/login)

Expected URLs:

API endpoint: http://10.0.0.110/api/auth/login
Login page: http://10.0.0.110/auth/login

Application Configuration:

# .env

AUTH_ORIGIN="http://10.0.0.110"
NUXT_AUTH_ORIGIN="http://10.0.0.110"
// nuxt.config.js

export default defineNuxtConfig({
  devtools: { enabled: true },
  devServer: {
    port: 80,
    host: '0.0.0.0'
  },
  modules: [
    '@sidebase/nuxt-auth'
  ],
  auth: {
    baseURL: 'http://10.0.0.110',
    provider: {
      type: 'local',
      pages: {
        login: '/auth/login'
      },
      endpoints: {
        signIn: { path: '/api/auth/login', method: 'post' },
        signOut: false,
        signUp: false,
        getSession: false
      },
      token: {
        maxAgeInSeconds: 3600,
        signInResponseTokenPointer: '/token/accessToken'
      }
    }
  },
  // available server-side only
  runtimeConfig: {
    authOrigin: '', // replaced by NUXT_AUTH_ORIGIN at runtime
  },
  // available for both server and client
  publicRuntimeConfig: {
    authOrigin: '', // replaced by NUXT_AUTH_ORIGIN at runtime
  }
})

Additional context

No response

Logs

No response

@phuze phuze added bug A bug that needs to be resolved pending labels Apr 30, 2024
@phuze
Copy link
Author

phuze commented Apr 30, 2024

I've just come across issue #368.

It appears the only way to get this to work correctly, is by including a trailing slash at the end of the baseURL, and removing the leading slashes from the endpoints and pages paths.

Hopefully this bug is fixed in a future release of sidebase/nuxt-auth.

// nuxt.config.js

export default defineNuxtConfig({
  auth: {
    baseURL: 'http://10.0.0.110/',
    provider: {
      type: 'local',
      pages: {
        login: 'auth/login'
      },
      endpoints: {
        signIn: { path: 'api/auth/login', method: 'post' },
        signOut: false,
        signUp: false,
        getSession: false
      },
      token: {
        maxAgeInSeconds: 3600,
        signInResponseTokenPointer: '/token/accessToken'
      }
    }
  }
})

@phuze phuze closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that needs to be resolved pending
Projects
None yet
Development

No branches or pull requests

1 participant