'How can I deploy a gatsby site and a react app on the same domain, but render a different root page based on authentication status?
I have a react app and a gatsby site that I would like to deploy on the same domain.
The app and the website have non conflicting routes for all pages except for the root page /.
Ex.
Website
/
/blog/example-1
/blog/example-2
/about
/pricing
App
/
/:id
/profile
/settings
/new
There is plenty of documentation on how to deploy 2 apps that have non conflicting domains but how can I serve the website root path (/) when the user is not authenticated and the app root path (/) when the user is authenticated.
I'm deploying with Heroku and my authentication is done through Auth0.
How can I do this? Options I'm considering/finding are:
- Add some sort of proxy (HAProxy, Caddy) in front of the app that determines if the user is authenticated and serves the correct page.
- Building the website alongside the app but using SSR for the website for SEO purposes
- Something else?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
