You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/advanced/deployment/self-hosted.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This guide will explain how you can self-host a Nuxt3 application running NuxtAu
6
6
7
7
When deploying the Auth.JS provider, the application must be informed what URL it is running at. This is to properly determine callback urls when navigating users to external OAuth providers. Depending on your setup, NuxtAuth allows you to set this value at either [**Runtime**](https://nuxt.com/docs/guide/going-further/hooks#app-hooks-runtime) or [**Buildtime**](https://nuxt.com/docs/guide/going-further/hooks#nuxt-hooks-build-time).
8
8
9
-
-**Runtime:** Set the `AUTH_ORIGIN` environment variable.
9
+
-**Runtime:** Set the `NUXT_AUTH_ORIGIN` environment variable.
10
10
-**Buildtime:** Set the `baseURL`-config key inside the `nuxt.config.ts`
-**port:** empty (implies `:80` for http and `:443` for https), :3000, :8888
17
17
18
-
An example of the `AUTH_ORIGIN` would be: `https://my-awesome-app.com`
18
+
An example of the `NUXT_AUTH_ORIGIN` would be: `https://my-awesome-app.com`
19
19
20
20
:::info Origin Order
21
21
When [attempting to determine the server origin](https://github.com/sidebase/nuxt-auth/blob/main/src/runtime/server/services/utils.ts#L11), NuxtAuth checks the available options in the following order:
22
-
-**Prio 1**: Using `AUTH_ORIGIN`
22
+
-**Prio 1**: Using `NUXT_AUTH_ORIGIN`
23
23
-**Prio 2**: Using `baseURL`-config key from inside the `nuxt.config.ts`
24
24
-**Prio 3**: Infer the origin _(Only in development)_
25
25
:::
26
26
27
27
:::tip
28
-
We recommend setting the `AUTH_ORIGIN` during runtime and leaving the `baseURL`-config key empty, to avoid using a potentially incorrect ORIGIN.
28
+
We recommend setting the `NUXT_AUTH_ORIGIN` during runtime and leaving the `baseURL`-config key empty, to avoid using a potentially incorrect ORIGIN.
29
29
:::
30
30
31
31
In addition to verifying that the origin is correctly set, also ensure that you have a secure [`secret` set in the NuxtAuthHandler](/guide/authjs/nuxt-auth-handler#secret).
The name of the environment variable that holds the origin of the application. This is used to determine the origin of your application in production. Read more [here](/resources/error-reference#auth-no-origin).
`AUTH_NO_ORIGIN` will appear as a warning message during development and be thrown as an error that stops the application during production. It is safe to ignore the development warning - it is only meant as a heads-up for your later production-deployment. `AUTH_NO_ORIGIN` occurs when the origin of your application was not set. NuxtAuth tries to find the origin of your application in the following order:
23
23
24
-
1. Use the `AUTH_ORIGIN` environment variable if it is set,
24
+
1. Use the `NUXT_AUTH_ORIGIN` environment variable if it is set
25
25
2. Development only: Determine the origin automatically from the incoming HTTP request
26
26
27
-
28
27
The `origin` is important for callbacks that happen to a specific origin for `oauth` flows. Note that in order for (2) to work the `origin` already has to be set at build-time, i.e., when you run `npm run build` or `npm run generate` and it will lead to the `origin` being inside your app-bundle.
28
+
29
+
```ts
30
+
// file: nuxt.config.ts
31
+
exportdefaultdefineNuxtConfig({
32
+
runtimeConfig: {
33
+
authOrigin: 'https://example.org', // You can either set a default or leave it empty
* The name of the environment variable that holds the origin of the application. This is used to determine the full URL of the application in production.
410
+
* As an example, if you set `NUXT_AUTH_ORIGIN=http://example.org` in your `.env` file, the module will use this to determine the full URL of the application.
411
+
*
412
+
* Find more about this in the documentation: https://auth.sidebase.io/resources/error-reference#auth-no-origin
413
+
*
414
+
* @default 'AUTH_ORIGIN'
415
+
*/
416
+
originEnvKey?: string
408
417
/**
409
418
* Full url at which the app will run combined with the path to authentication. You can set this differently depending on your selected authentication-provider:
410
419
* - `authjs`: You must set the full URL, with origin and path in production. You can leave this empty in development
0 commit comments