N
Nuxt2d ago
Prestgg

I want to deploy my project on Nuxthub

auth: { isEnabled: true, originEnvKey: "NUXT_AUTH_ORIGIN", baseURL: process.env.NUXT_BASE_URL, provider: { type: "authjs", addDefaultCallbackUrl: true, }, }, runtimeConfig: { public: { authOrigin: process.env.NUXT_AUTH_ORIGIN, }, }, And my env file NUXT_AUTH_ORIGIN0=https://aze-script-prestgg1.nuxt.dev NUXT_BASE_URL=https://aze-script-prestgg1.nuxt.dev But I have an error [10:23:52] ERROR Failed to publish your Function. Got error: Uncaught Error: AUTH_NO_ORIGIN: No origin - this is an error in production, see https://sidebase.io/nuxt-auth/resources/errors. You can ignore this during development at chunks/nitro/nitro.mjs:1:89639 in getServerBaseUrl at chunks/nitro/nitro.mjs:13:91796 in Si
2 Replies
kapa.ai
kapa.ai2d ago
Hi @Prestgg. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on your configuration and the error message, there are a few key points to check when deploying to NuxtHub: 1. Environment Variable Naming
Your .env file contains NUXT_AUTH_ORIGIN0, but your code references process.env.NUXT_AUTH_ORIGIN. The variable name in your .env file must exactly match what you reference in your code.
Change your .env to:
NUXT_AUTH_ORIGIN=<https://aze-script-prestgg1.nuxt.dev>
NUXT_BASE_URL=<https://aze-script-prestgg1.nuxt.dev>

NUXT_AUTH_ORIGIN=<https://aze-script-prestgg1.nuxt.dev>
NUXT_BASE_URL=<https://aze-script-prestgg1.nuxt.dev>

Remove the 0 from NUXT_AUTH_ORIGIN0. 2. Runtime Config and Environment Variables
Nuxt expects environment variables to be prefixed with NUXT_ and, for public runtime config, with NUXT_PUBLIC_ if you want them exposed to the client. However, for your use case, NUXT_AUTH_ORIGIN is fine for server-side use, and you are correctly exposing it in runtimeConfig.public for client-side access.
Make sure your nuxt.config.ts looks like:
export default defineNuxtConfig({
auth: {
isEnabled: true,
originEnvKey: "NUXT_AUTH_ORIGIN",
baseURL: process.env.NUXT_BASE_URL,
provider: {
type: "authjs",
addDefaultCallbackUrl: true,
},
},
runtimeConfig: {
public: {
authOrigin: process.env.NUXT_AUTH_ORIGIN,
},
},
})

export default defineNuxtConfig({
auth: {
isEnabled: true,
originEnvKey: "NUXT_AUTH_ORIGIN",
baseURL: process.env.NUXT_BASE_URL,
provider: {
type: "authjs",
addDefaultCallbackUrl: true,
},
},
runtimeConfig: {
public: {
authOrigin: process.env.NUXT_AUTH_ORIGIN,
},
},
})

3. Deploying to NuxtHub
When deploying to NuxtHub, ensure your environment variables are set in the deployment environment, not just in your local .env file. NuxtHub (and most serverless/cloud platforms) require you to set environment variables in their dashboard or deployment configuration, as .env files are not automatically loaded in production.
See the Nuxt documentation:
Nuxi CLI has built-in support for reading your .env file in development, build and generate. But when you run your built server, your .env file will not be read.
Runtime config values are automatically replaced by matching environment variables at runtime.
Nuxt Runtime Config Docs 4. Error Explanation
The error AUTH_NO_ORIGIN: No origin - this is an error in production means that the required origin environment variable is not being found at runtime. This is likely because the variable is not set in the NuxtHub deployment environment. Summary of what to do: - Fix your .env variable name to NUXT_AUTH_ORIGIN. - Make sure to set NUXT_AUTH_ORIGIN and NUXT_BASE_URL in the NuxtHub dashboard or deployment settings, not just in your local .env file. - Redeploy your project. If you follow these steps, your deployment should correctly pick up the environment variables and resolve the AUTH_NO_ORIGIN error. For more details, see the official Nuxt documentation on runtime config and environment variables and NuxtHub deployment. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2d ago
<@582277346934128651> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?