Skip to content

Commit

Permalink
Fixed Authentication docs improper nesting of unordered list inside o…
Browse files Browse the repository at this point in the history
…rdered list (#62958)

On the Building Your Application: Authentication page, the formatting is
broken in the "Setting Up Middleware" section because the unordered list
is nested inside the ordered list. This is causing the unordered list
components to be numbered and throw off the ordering of the top level
list.

I made a tiny change to the markdown to make the top level steps h4
titles, and un-nested the unordered list's

Closes NEXT-61838
Fixes #61838

Co-authored-by: Sam Ko <sam@vercel.com>
  • Loading branch information
landoncolburn and samcx authored Mar 11, 2024
1 parent a00458b commit cc57fe8
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,22 @@ Once a user is authenticated, you'll need to ensure the user is allowed to visit

Here's how to implement Middleware for authentication in Next.js:

1. **Setting Up Middleware:**
- Create a `middleware.ts` or `.js` file in your project's root directory.
- Include logic to authorize user access, such as checking for authentication tokens.
2. **Defining Protected Routes:**
- Not all routes require authorization. Use the `matcher` option in your Middleware to specify any routes that do not require authorization checks.
3. **Middleware Logic:**
- Write logic to verify if a user is authenticated. Check user roles or permissions for route authorization.
4. **Handling Unauthorized Access:**
- Redirect unauthorized users to a login or error page as appropriate.
#### Setting Up Middleware:

- Create a `middleware.ts` or `.js` file in your project's root directory.
- Include logic to authorize user access, such as checking for authentication tokens.

#### Defining Protected Routes:

- Not all routes require authorization. Use the `matcher` option in your Middleware to specify any routes that do not require authorization checks.

#### Middleware Logic:

- Write logic to verify if a user is authenticated. Check user roles or permissions for route authorization.

#### Handling Unauthorized Access:

- Redirect unauthorized users to a login or error page as appropriate.

Example Middleware file:

Expand Down

0 comments on commit cc57fe8

Please sign in to comment.