Closed quenginedev closed 1 month ago
After digging around in the code and reading the deployment docs, I found that Nuxt does not use the .env file when building for production.
o fix this issue, I used the kinde options in the nuxt.config.ts file as shown below:
export default defineNuxtConfig({
devtools: { enabled: true },
nitro: {
preset: "cloudflare-pages",
},
kinde: {
debug: true,
password: process.env.NUXT_KINDE_PASSWORD,
authDomain: process.env.NUXT_KINDE_AUTH_DOMAIN,
clientId: process.env.NUXT_KINDE_CLIENT_ID,
redirectURL: process.env.NUXT_KINDE_REDIRECT_URL,
logoutRedirectURL: process.env.NUXT_KINDE_LOGOUT_REDIRECT_URL,
postLoginRedirectURL: process.env.NUXT_KINDE_POST_LOGIN_REDIRECT_URL,
clientSecret: process.env.NUXT_KINDE_CLIENT_SECRET,
audience: process.env.NUXT_KINDE_AUDIENCE,
},
modules: [
"nitro-cloudflare-dev",
"nuxt-typed-router",
"@nuxtjs/tailwindcss",
"@vueuse/nuxt",
"@formkit/auto-animate",
"@nuxtjs/color-mode",
"dayjs-nuxt",
"nuxt-icon",
"@nuxtjs/kinde",
"./modules/my-app-module",
],
colorMode: {
classSuffix: "",
preference: "light",
fallback: "light",
},
});
This approach ensures that the environment variables are correctly passed to the Nuxt configuration in production.
GitHub Issue: Internal Server Error with
/api/login
and/api/register
Links in ProductionIssue Description:
I am encountering an issue with the
/api/login
and/api/register
endpoints in my Nuxt.js application. The problem arises when using theNuxtLink
,LoginLink
, orRegisterLink
components with the paths specified in the @nuxt/kinde documentation.Steps to Reproduce:
NuxtLink
,LoginLink
, orRegisterLink
components to navigate to/api/login
or/api/register
.npm run build
.Observed Behavior:
/api/login
and/api/register
works correctly.No match found for location with path "/api/login"
No match found for location with path "/api/register"
Expected Behavior:
The login and register links should work seamlessly in both development and production environments without resulting in internal server errors.
Configuration Details:
package.json
:nuxt.config.ts
:Additional Information:
wrangler pages deploy
.Request for Assistance:
I would appreciate any insights or suggestions on how to resolve this issue. Specifically, I need help understanding why the login and register links result in an internal server error in production and how to fix this.
Thank you for your assistance!