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

feat: allow custom base path #169

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

freality
Copy link

πŸ”— Linked issue

Allow custom base path other than /api/auth #168

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

By allowing the user to configure a basePath, the user can implement their NuxtAuthHandler on any route they chose.

This PR adds an optional basePath to the module configuration object (with default /api/auth for backwards compatibility). It generates a #build/auth.config.mjs with #auth-config alias. And uses the configuration variable where needed.

Docs are also updated to include the new basePath configuration.

resolves #168

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

* add basePath to module config w/ default /api/auth
* generate auth.config.mjs module file
* add #auth-config alias
replace hardcoded basePath with config variable
Use ufo for url manipulation to avoid bad string joins
Copy link
Owner

@Hebilicious Hebilicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for contributing.
This is looking great!
Looks like the tests are failing so this will need a bit more work.
Could you try to remove the ts-expect errors and add a declaration file to handle the config?

packages/authjs-nuxt/src/runtime/lib/server.ts Outdated Show resolved Hide resolved
packages/authjs-nuxt/src/runtime/lib/client.ts Outdated Show resolved Hide resolved
@freality
Copy link
Author

Looks like the tests are failing so this will need a bit more work.

I'm seeing the same build error when run against the main branch.

@mdowton
Copy link

mdowton commented Mar 22, 2024

Really looking for the feature also is blocking our current work any update @Hebilicious

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom base path other than /api/auth
3 participants