An example that shows how you can use Vercel 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: An app that you want to password protect
- Auth: An app that takes a password and sets a cookie to grant access to the dashboard
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
.
- Run
npm install
- In one terminal window run
npm start -w auth
- In another terminal window run
npm start -w dashboard
- Go to http://localhost:3000