I've been stuck on this for over a week now and its driving me bonkers haha. Essentially I have a react app I created for a client that wants it to display at clientdomain.com/react-app. I'm using docker to spin up a container that's running at localhost:8000. When I visit localhost:8000/react-app the project displays properly as I have the app routing there using react-router. Unfortunately when visiting the target url and path it's blank and has a few of these errors in console; Loading failed for the <script> with source “https://clientdomain.com/static/js/2.f5d5b027.chunk.js”
here is the nginx config for the clients site with the location config i've added at location /react-app
server {
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
server_name clientdomain.com www.clientdomain.com;
root /var/www/clientdomain;
index index.php index.html index.htm;
rewrite ^/artiklar/([^/]+)/$ /article-$1.php last;
location /react-app/ {
rewrite ^/react-app/(.*)$ /$1 break;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8000;
}
}
here is my Dockerfile
FROM mhart/alpine-node:11 AS builder
WORKDIR /app
COPY . .
FROM mhart/alpine-node
RUN yarn global add serve
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-p", "80", "-s", "."]
Also this is the /var/www/html folder structure
/var/www/html
/var/www/clientsdomain
/var/www/react-app
Ive also tried to use just serve -s build and remote proxy to the localhost it is being served at but the same issue occurs.
These are the docker commands that are being used as well to build and run
docker build -t react-app .
docker run -it -p 8000:80 react-app
Thanks!!
localhost:8000orlocalhost:8000/react-app?