/vercel-middleware-auth-demo

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

Primary LanguageTypeScript

Vercel Middleware Auth Demo

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

Demo

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
  2. In one terminal window run npm start -w auth
  3. In another terminal window run npm start -w dashboard
  4. Go to http://localhost:3000