strapi icon indicating copy to clipboard operation
strapi copied to clipboard

Problem with docker when using a reverse proxy

Open liqueflies opened this issue 6 years ago • 3 comments

Version

@nuxtjs/strapi: v0.1.6 nuxt: v2.14.5

Steps to reproduce

I have a docker-compose with nuxt and strapi, on the top a reverse proxy that handle routing using Virtual hosts that use http://my.project.test for nuxt and http://api.my.project.test for strapi.

If I call on the client http://api.my.project.test everything is going ok. If I made the same call on the server tries to connect to the 80 port instead of 1337

FetchError: request to http://api.my.project.test/users/me failed, reason: connect ECONNREFUSED xxx.xx.xx.xx:80 If into server I call to http://strapi:1337 everything is going ok, but the client is broken.

I read this is a common problem with docker, nuxt and strapi (you can look also at this: https://stackoverflow.com/a/55090981)

So debugging the source I checked the http-module. It should give you the opportunity to set both client and server url, but strapi-module set a unique url and with this line (https://github.com/nuxt-community/strapi-module/blob/c65a31cd5518f3387855a741a1dac7618958c93e/lib/plugin.js#L19) it override http-module settings.

What is Expected?

I expect to use the nuxt http: {} config (https://http.nuxtjs.org/api/#baseurl & https://http.nuxtjs.org/api/#browserbaseurl) or strapi module could proxy these settings.

What is actually happening?

In server mode, fetchUser is going to fail.

liqueflies avatar Sep 25 '20 09:09 liqueflies

I think the temporary workaround would be by using reverse proxy (nginx) on your docker containers and reference client-side link on both server and client.

dawidstefaniak avatar Oct 04 '20 12:10 dawidstefaniak

Could you by using the proxy mode? https://strapi.nuxtjs.org/proxy

atinux avatar Dec 18 '20 12:12 atinux

This has been closed for a while - but I've struggled to configure the proxy module. Is there any config examples out there with .env setups?

gwynhokkers avatar Jul 05 '21 15:07 gwynhokkers