Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/dommi10/nuxt-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
dommi10 committed Nov 22, 2023
2 parents 1d3da04 + 3f033cc commit 627489b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
4 changes: 1 addition & 3 deletions docs/content/2.configuration/3.nuxt-auth-handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ This page is only relevant to you, if you are using the `authjs`-provider.
After following the [quick-start setup](/nuxt-auth/v0.6/getting-started/quick-start) and then optionally diving even deeper into the [`nuxt-auth` config inside your `nuxt.config.ts`](/nuxt-auth/v0.6/configuration/nuxt-config) you can begin defining providers and other options inside your `NuxtAuthHandler`.

For development, using the quick-start setup will already bring you quite far. For a production deployment, you will have to additionally:
- set the `origin` by:
1. exporting the `AUTH_ORIGIN`-environment variable _at runtime_ (higher precedence)
2. setting the `origin`-key inside the `nuxt.config.ts` config _at build-time_ (lower precendence)
- set the `origin` by exporting the `AUTH_ORIGIN`-environment variable _at runtime_
- set a secret inside the `NuxtAuthHandler` config

## Creating the `NuxtAuthHandler`
Expand Down
5 changes: 1 addition & 4 deletions docs/content/5.recipes/2.strapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For a production deployment, you will have to at least set the:
1. Create a `.env` file with the following lines:
```env
// Strapi v4 url, out of the box
ORIGIN=http://localhost:3000
AUTH_ORIGIN=http://localhost:3000
NUXT_SECRET=a-not-so-good-secret
STRAPI_BASE_URL=http://localhost:1337/api
```
Expand All @@ -28,9 +28,6 @@ export default defineNuxtConfig({
// Default http://localhost:1337/api
STRAPI_BASE_URL: process.env.STRAPI_BASE_URL,
},
auth: {
origin: process.env.ORIGIN,
},
});
```

Expand Down
4 changes: 2 additions & 2 deletions docs/content/5.recipes/6.laravel-passport.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default defineNuxtConfig({

```ts
// ~/server/api/auth/[...].ts
import {NuxtAuthHandler} from '#auth'
const {passport} = useRuntimeConfig(); //get the values from the runtimeConfig
import { NuxtAuthHandler } from '#auth'
const { passport } = useRuntimeConfig(); //get the values from the runtimeConfig

export default NuxtAuthHandler({
//...
Expand Down
4 changes: 2 additions & 2 deletions docs/content/5.recipes/7.vercel-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ In order to run the `nuxt-auth-example` the following environment variables are

When deploying `nuxt-auth` to Vercel you cannot set a random string as your nuxt secret. You must use a 32-bit generated secret. You can use [this](https://generate-secret.vercel.app/32) website to generate a custom secret.

### ORIGIN
### AUTH_ORIGIN

In order to set the correct origin go into your Vercel project settings and navigate to the `Domains` tab. Once there you will all the assigned domains and their assigned environment (production, dev).

Copy the correct domain for every enviroment and assign the environment variables to match the correct environment.
Copy the correct domain for every enviroment and assign the environment variables `AUTH_ORIGIN` to match the correct environment.

### Github_*

Expand Down
4 changes: 1 addition & 3 deletions docs/content/6.resources/5.errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ Read [the `NuxtAuthHandler` docs for more information and different options you

`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. `nuxt-auth` tries to find the origin of your application in the following order:
1. Use the `AUTH_ORIGIN` environment variable if it is set,
2. Use the `auth: { origin: 'https://your-cool-origin.com' }` config-value from the `nuxt.config.ts` if it is set,
3. Development only: Determine the origin automatically from the incoming HTTP request
2. Development only: Determine the origin automatically from the incoming HTTP request

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.

Read [the `nuxt.config.ts` docs for more information and different options you can use to set the `origin` at build- and at runtime](/nuxt-auth/v0.6/configuration/nuxt-auth-handler).

0 comments on commit 627489b

Please sign in to comment.