FusionAuth Node.js example
This project is two simple example Node.js applications that illustrates how you can easily implement multi tenant applications using FusionAuth.
To run
This assumes you already have a running FusionAuth instance, user and application running locally. If you don't, please see the 5-Minute Setup Guide to do so.
- Create two local aliases in your DNS:
hooli.localandpiedpiper.local, both resolving to127.0.0.1. - Log into the FusionAuth admin panel
- Create two tenants,
Hooli TenantandPied Piper Tenant - Create two applications,
HooliandPied Piper- Update the
HooliFusionAuth application to allow a redirect ofhttp://hooli.local:3001/oauth-redirect - Update the
Pied PiperFusionAuth application to allow a redirect ofhttp://piedpiper.local:3000/oauth-redirect
- Update the
- Create a user in each tenant. They can have different passwords.
- Make sure your user has a first name.
- Register your user for the applications in the corresponding tenant.
- Return to your terminal window.
- In the
hoolidirectory, run:npm install- update
routes/index.jswith the client id and client secret of your FusionAuth application. PORT=3001 npm start
- In the
piedpiperdirectory, run:npm install- update
routes/index.jswith the client id and client secret of your FusionAuth application. PORT=3000 npm start
Open an incognito browser (or a different one)
Go to http://hooli.local:3001/ and login with the previously created user for the Hooli application.
You should see 'Hello [firstname]'.
Then go to http://piedpiper.local:3000. You will be prompted to sign in again with the different password.