admin管理员组文章数量:1319013
I am working on Next.js project in which I have implemented user authentication using next-auth and Google Provider. When I am trying to create the build for the project the the plier throws this error "Error: Page "/api/auth/[...nextauth]" is missing "generateStaticParams()" so it cannot be used with "output: export" config." This is my api > auth > [...nextauth] > route.js file
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google"
export const authoptions = {
providers : [
GoogleProvider({
clientId : process.env.GOOGLE_CLIENT_ID,
clientSecret : process.env.GOOGLE_CLIENT_SECRET
})
],
secret : process.env.NEXTAUTH_SECRET,
callbacks : {
async redirect(){
return process.env.NEXTAUTH_URL;
}
}
}
const handler = NextAuth(authoptions)
export {handler as GET, handler as POST}
This is my code for api > auth > [...nextauth] > route.js file
/** @type {import('next').NextConfig} */
const nextConfig = {
output : "export"
}
module.exports = nextConfig
This my code for next.config.js file
I am working on Next.js project in which I have implemented user authentication using next-auth and Google Provider. When I am trying to create the build for the project the the plier throws this error "Error: Page "/api/auth/[...nextauth]" is missing "generateStaticParams()" so it cannot be used with "output: export" config." This is my api > auth > [...nextauth] > route.js file
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google"
export const authoptions = {
providers : [
GoogleProvider({
clientId : process.env.GOOGLE_CLIENT_ID,
clientSecret : process.env.GOOGLE_CLIENT_SECRET
})
],
secret : process.env.NEXTAUTH_SECRET,
callbacks : {
async redirect(){
return process.env.NEXTAUTH_URL;
}
}
}
const handler = NextAuth(authoptions)
export {handler as GET, handler as POST}
This is my code for api > auth > [...nextauth] > route.js file
/** @type {import('next').NextConfig} */
const nextConfig = {
output : "export"
}
module.exports = nextConfig
This my code for next.config.js file
Share Improve this question asked Nov 26, 2023 at 5:00 swetanshu singhswetanshu singh 611 silver badge3 bronze badges 6- do you have any dynamic route in your project? – Yilmaz Commented Nov 28, 2023 at 0:46
- @Yilmaz yes I have a dynamic route. – swetanshu singh Commented Nov 28, 2023 at 1:47
-
does not this
output : "export"
mean you are building a static app – Yilmaz Commented Nov 28, 2023 at 1:48 - yes, I read the docs and realized that I was creating the build wrong way. @Yilmaz Can you help in creating the build. I am not building a static app – swetanshu singh Commented Nov 28, 2023 at 1:59
-
just run
npm run build
?? – Yilmaz Commented Nov 28, 2023 at 2:06
1 Answer
Reset to default 8If you are not building a static site then remove output : "export" from the nextConfig file. The authentication process is dynamic thus can not be rendered as static.
本文标签:
版权声明:本文标题:javascript - Error: Page "apiauth[...nextauth]" is missing "generateStaticParams()" so it ca 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742050395a2418035.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论