N
Nuxt4mo ago
jd

Docker and Nuxt in production

I can't find the way to ask me question concisely But I need help deploying my nuxt app in production I'm currently running into the issue that my nuxt app (built with generate, ie SSG), and I can't find a way to make it use the right api base url to perform the requests through to the other docker container where the api is exposed through the docker network (but I don't want to expose the api to the public). Anyone with experience with that that can help me out?
5 Replies
Single
Single4mo ago
You simply can't. The API call is not being made by the Webserver that is hosting the SSG/Frontend, but the Client (Browser) that visits the site. If this client has no access to the (exposed) API, you can't not do requests against it.
Single
Single4mo ago
What we do is, we use a reverse-proxy like https://traefik.io/traefik/ to give managed access to the API and thus expose it to the public.
Traefik Labs: Say Goodbye to Connectivity Chaos
Traefik, The Cloud Native Application Proxy | Traefik Labs
Traefik is the leading open-source reverse proxy and load balancer for HTTP and TCP-based applications that is easy, dynamic and full-featured.
jd
jdOP3mo ago
I realized that SSG isn't the way to go, but wouldn't a build (SSR) work for that purpose? I've actually been able to make it work, but I'm running into a new challenge now, the api container/host doesn't resolve The config is api:8000 and it treats api as a string instead of the network address
xmatthias
xmatthias3mo ago
well an app will not be "ssr only" - so if you implement a "refresh" button in the UI (for example) - then that'll trigger from the hydrated client browser app
Single
Single3mo ago
You need to expose something. If you do not want to expose the API directly, you can use nitro (nuxt-server) as a proxy. In this case, "only" the server has to be exposed but not the api directly. Does this make sense? I guess not.
Want results from more Discord servers?
Add your server