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/application-side/configuration.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,27 @@ Whether the module is enabled at all
31
31
-**Type**: `string`
32
32
-**Default**: `AUTH_ORIGIN`
33
33
34
-
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).
34
+
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.
35
+
36
+
By default, NuxtAuth will look at `AUTH_ORIGIN` environment variable and `runtimeConfig.authOrigin`.
37
+
38
+
::: tip
39
+
If you want to use `runtimeConfig` and `NUXT_` prefixed environment variables, you need to make sure to also define the key inside `runtimeConfig`,
40
+
because otherwise Nuxt will not acknowledge your env variable ([issue #906](https://github.com/sidebase/nuxt-auth/issues/906), read more [here](https://nuxt.com/docs/guide/going-further/runtime-config#environment-variables)).
41
+
42
+
```ts
43
+
exportdefaultdefineNuxtConfig({
44
+
auth: {
45
+
originEnvKey: 'NUXT_YOUR_ORIGIN'
46
+
},
47
+
runtimeConfig: {
48
+
yourOrigin: ''
49
+
}
50
+
})
51
+
```
52
+
:::
53
+
54
+
You can read additional information on `origin` determining [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:
22
+
`AUTH_NO_ORIGIN` will appear as a warning message during development and be thrown as an error that stops the application during production.
23
+
It is safe to ignore the development warning - it is only meant as a heads-up for your later production-deployment.
23
24
24
-
1. Use the `NUXT_AUTH_ORIGIN` environment variable if it is set
25
-
2. Development only: Determine the origin automatically from the incoming HTTP request
25
+
`AUTH_NO_ORIGIN` occurs when the origin of your application was not set.
26
+
NuxtAuth attempts to find the origin of your application in the following order ([source](https://github.com/sidebase/nuxt-auth/blob/9852116a7d3f3be56f6fdc1cba8bdff747c4cbb8/src/runtime/server/services/utils.ts#L8-L34)):
26
27
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
+
### 1. Environment variable and `runtimeConfig`
29
+
30
+
Use the `AUTH_ORIGIN` environment variable or `runtimeConfig.authOrigin` if set. Name can be customized, refer to [`originEnvKey`](/guide/application-side/configuration#originenvkey).
31
+
32
+
### 2. `baseURL`
33
+
34
+
The `origin` is computed using `ufo` from the provided `baseURL`. See implementation [here](https://github.com/sidebase/nuxt-auth/blob/9852116a7d3f3be56f6fdc1cba8bdff747c4cbb8/src/runtime/helpers.ts#L9-L23).
28
35
29
36
```ts
30
-
// file: nuxt.config.ts
31
37
exportdefaultdefineNuxtConfig({
32
-
runtimeConfig: {
33
-
authOrigin: 'https://example.org', // You can either set a default or leave it empty
0 commit comments