I have a SPA (Single Page App) with JS and an index.html
.
I'm serving it with my backend Golang app from /public
dir.
I'm deploying this Golang app on Heroku: everything works!
Now I'm building an SSR (Server Side Rendered) app using Svelte Kit (or NextJS, I still have to decide).
GIVEN:
The SSR app is a NodeJS app which requires a dedicated Heroku dyno: I think I cannot serve it like I do now from /public
dir.
Leaving aside the additional cost for the dedicated dyno, now there are also new problems of the additional latency given by:
frontend SSR app (on
frontend.herokuapp.com
) needs to callbackend.herokuapp.com
;new CORS calls for the different domains
QUESTION:
Is there a way to deploy both apps on the same dyno?
Maybe with a proxy (ex: nginx or HA) in front of them so that I can have a single domain with both:
myapp.heroku.com
--> serving SSR app (index.html
which can call my backend using/api
and NOTbackend.herokuapp.com/api
)myapp.heroku.com/api
--> which can be called from the frontend app without CORS calls
Am I totally crazy?
CONTEXT:
It's a small app with few views.