An open API service indexing awesome lists of open source software.

https://github.com/iansu/vercel-middleware-auth-demo

An example that shows how you can use Vercel Middleware to control access to an app
https://github.com/iansu/vercel-middleware-auth-demo

Last synced: about 2 months ago
JSON representation

An example that shows how you can use Vercel Middleware to control access to an app

Awesome Lists containing this project

README

          

# Vercel Middleware Auth Demo

An example that shows how you can use [Vercel Middleware](https://nextjs.org/docs/advanced-features/middleware) to control access to an app

> **Warning**
> This only provides limited protection and it's easy for users to duplicate the auth cookie. Make sure you understand the risks and tradeoffs before using this in a production application.

This repo includes two apps:

- [Dashboard](./apps/dashboard): An app that you want to password protect
- [Auth](./apps/auth): An app that takes a password and sets a cookie to grant access to the dashboard

## Demo

[https://dashboard.vercel-middleware-auth-demo.iansutherland.dev](https://dashboard.vercel-middleware-auth-demo.iansutherland.dev)

You should be asked to login and then redirected back to the dashboard app. You can login with the passwords `password` and `secret`.

## Development

1. Run `npm install`
1. In one terminal window run `npm start -w auth`
1. In another terminal window run `npm start -w dashboard`
1. Go to [http://localhost:3000](http://localhost:3000)