-
Notifications
You must be signed in to change notification settings - Fork 925
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
not work with nuxt 3 #1323
Comments
Nuxt 3 hasn't even been in beta for 2 weeks yet... |
It's not released for nuxt3 yet. Follow the module compatibility here: https://github.com/nuxt/framework/discussions/751 |
Here is the latest issue related to this module: nuxt-community/auth-module#1323
Did you tried it with Nuxt Bridge? Do you mind submitting your findings or updates here please? https://isnuxt3ready.owln.ai/ |
We haven't had time to investigate this - so more information, investigation, and PRs would all be very welcomed. |
Hi, did anyone take a look in the meantime? |
It will certainly be part of v5/auth-next. First task on the list is to upgrade packages one-by-one; help with that is welcomed. Just create a PR with one upgraded package, make sure it passes yarn test and the demo application (yarn dev) works. |
Works perfectly on nuxt bridge |
Should probably make sure v5 work on both Nuxt 2 and Nuxt 3 when it launch. Otherwise v5 should focus on Nuxt 2 and a v6 should be created for Nuxt 3 |
@bmulholland which branch would that be then? |
Yes, auth-next is the dev branch |
Si v5 will still be compatible with Nuxt 2 or supporting Nuxt 3 has breaking change ? |
I don't know yet |
IMHO, v5 should support Nuxt 2 as a lot of people are already using it with If there is breaking change to support Nuxt 3, I think v5 should be finished with only Nuxt 2 support and a new v6 should be started for Nuxt 3. |
@mrleblanc101 Thanks, I understood your point in your original comment. We'll make sure we provide appropriate nuxt version support for whatever is needed. Your PRs to help out are welcomed. |
@bmulholland is the
|
@hartmut-co-uk Honestly I haven't fired it up myself for some time, and so basic fixes for Re: playwright, I'm hoping that upgrading it will add M1 support. |
|
For me it doesn't work with Nuxt Bridge. As soon as I add router: {
base: '/',
middleware: ['auth'],
linkActiveClass: 'active',
linkExactActiveClass: 'exact-active',
extendRoutes(routes) {
routes.push({
path: '/',
redirect: '/write',
})
}
} I get the following error when I try to start the dev server with If I remove Digging into the source file that causes the error it happens in Is this a problem of the |
IMO the config format you included should be supported by nuxt, so I think it's an issue with nuxt bridge - could you please file an issue over there? |
@bmulholland yes will do, thanks! |
I have tested it with Nuxt 3 Bridge and it's working like it's supposed to after following the guide. EDIT: Removed this section, reason: I did not see you had set the property correctly The only bug I'm experiencing is when I log in and refresh the page the middleware can't detect I'm logged in and redirects me to the login page. However, the store is correct and has the fetched user object and has the My full `nuxt.config.js`import { defineNuxtConfig } from '@nuxt/bridge'
export default defineNuxtConfig({
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'auth-test',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'ant-design-vue/dist/antd.css'
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
'@/plugins/antd-ui'
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
// https://dev.auth.nuxtjs.org/
'@nuxtjs/auth-next'
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
prefix: '/api/',
credentials: true,
proxy: true,
},
proxy: {
'/api/': { target: 'http://localhost:8000/', pathRewrite: { '^/api/': '' } }
},
// Auth module configuration: https://dev.auth.nuxtjs.org/
auth :{
strategies: {
local: {
token: {
property: 'token',
global: true,
required: true,
type: 'Bearer'
},
user: {
property: 'user',
autoFetch: true
},
endpoints: {
login: { url: '/login', method: 'post' },
logout: { url: '/logout', method: 'get' },
user: { url: '/user', method: 'get' }
}
}
},
// redirect: {
// login: '/login',
// logout: '/',
// callback: '/login',
// home: '/profile'
// }
},
router: {
middleware: [
'auth',
],
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
//
}
}) |
Hey @TimVanHerwijnen, thanks for digging in! I just raised the issue in the Nuxt repo (nuxt/bridge#164) and created a reproduction: Github: https://github.com/toniengelhardt/nuxt-bridge-debug Note that the router config also includes the middleware setting as specified in the docs. When I first tried to reproduce the problem from scratch I also didn't see it at first, but when I added more packages and modules from my project repo it showed up, so it seems like it is clashing with some other module or package. |
I am now taking the refresh (jwt) approach and got the auth module completely working now without any issues.
So I am convinced this is a configuration or a Vite error. Since I don't have this issue and I am not using Vite. My dependencies:"dependencies": {
"@nuxtjs/auth-next": "^5.0.0-1637745161.ea53f98",
"@nuxtjs/axios": "^5.13.6",
"ant-design-vue": "^1.7.8",
"core-js": "^3.15.1",
"nuxt-edge": "^2.16.0-27322574.c1d02ea3"
},
"devDependencies": {
"@nuxt/bridge": "npm:@nuxt/bridge-edge"
} What I've tested and is working as supposed:
My updated `nuxt.config.js`import { defineNuxtConfig } from '@nuxt/bridge'
export default defineNuxtConfig({
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'fusionauth-test',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'ant-design-vue/dist/antd.css'
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
'@/plugins/antd-ui',
'@/plugins/axios',
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
// https://dev.auth.nuxtjs.org/
'@nuxtjs/auth-next'
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
baseURL: 'http://localhost:8080/', // Nuxt host url
credentials: true,
proxy: true,
},
proxy: {
'/auth/': { target: process.env.FUSIONAUTH_URL, pathRewrite: { '^/auth/': '' } }
},
// Auth module configuration: https://dev.auth.nuxtjs.org/
auth :{
localStorage: false,
resetOnError: true,
strategies: {
local: {
scheme: 'refresh',
tokenType: 'JWT',
token: {
property: 'token',
maxAge: 60 * 10, // 10 Minutes
global: true,
},
refreshToken: {
tokenRequired: true,
property: 'refreshToken',
data: 'refreshToken',
maxAge: 60 * 60 * 24 * 30 // 30 Days
},
user: {
property: 'user',
autoFetch: true
},
endpoints: {
login: { url: 'auth/api/login', method: 'post' },
refresh: { url: 'auth/api/jwt/refresh', method: 'post' },
logout: { url: 'auth/api/logout', method: 'post' },
user: { url: 'auth/api/user', method: 'get' }
},
autoLogout: false
}
},
redirect: {
login: '/login',
logout: '/',
home: '/profile',
callback: '/login',
}
},
router: {
middleware: [
'auth',
],
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
//
}
}) |
Interesting, so it probably is a Vite bug. I also have other errors when disabling Vite in my project, but I'll try to resolve and confirm that it works without Vite and then raise an issue in the Nuxt repo. |
Quick update: I upgraded packages and fixed I've also added a request for assistance with some specific tasks over at #1393. If you find anything specific that is needed -- or helpful -- for nuxt bridge or nuxt 3, please let me know and I'll add it to the list. |
👍 I can now run and start in dev mode from latest So much for quick feedback. |
Ah I'd added a note on running tests to the readme, but it was stuck in a branch. Just pushed it, does this help? https://github.com/nuxt-community/auth-module#development |
thx, all tests pass! |
@hartmut-co-uk Good news ! Are you on Nuxt-Bridge or Nuxt 3 ? |
This comment was marked as off-topic.
This comment was marked as off-topic.
@linhherrera96 Use Nuxt 2 as Nuxt 3 is still in Beta or wait for a Nuxt 3 version of this plugin. |
so is there any library to replace it? Currently I am using Nuxt 3 to do project. |
So I've noticed on the Nuxt 3 roadmap they are working on it, but in a private beta. So I think we'll have to wait since there are no alternatives yet. |
@TimVanHerwijnen do you have nuxt/auth running with Bridge and Vite? I'm having a middleware issue mentioned here: #1519 |
@toniengelhardt I do have it running with Edit: |
Anyone have this running with Nuxt Bridge? Currently seeing this:
|
Thanks! I looked into the examples. But how would I restrict certain pages? For example:
|
This exampe page shows how to use it in restricted pages. For public pages, you don't need ref: const { $oidc } = useNuxtApp() at setup script, which page can't get use info. |
anyone using @nxutjs-alt/auth in the meantime? I'm getting |
I only got it working with Vite + Nuxt Bridge Next by adding this to my nuxt config. Hope it helps someone out.
|
@Slaknoah could you share your full config? That would be amazing! |
Is there a replacement now? |
https://www.npmjs.com/package/@nuxtjs-alt/auth works fine, but it's diverged from slightly from @nuxtjs/auth |
Cannot start nuxt
The text was updated successfully, but these errors were encountered: