So I'm writing a series of automated tests for a single page react application. The tests rely on a mocked api that's exposed on a different port than the application is served from. In order to get around cors issues, the local-web-server instance that serves the SPA is set up to proxy api requests to the backend. Here's the config file for the server:
const server = process.env.SERVER;
const port = process.env.PORT;
module.exports = {
port: port,
rewrite: [
{
from: '/api/(.*)',
to: `${server}/$1`
}
],
logFormat: 'tiny',
spa: 'index.html'
};
I'm using Selenium Test Containers, and the application is run from a docker image downloaded by the test code. Here's the docker file:
FROM node:10.16.0-alpine
ENV PORT=5000
COPY ./build ./
COPY ./docker ./
EXPOSE ${PORT}
RUN npm config set unsafe-perm true
RUN npm install local-web-server -g
CMD ws --config-file web-server-config.js
The issue that I've been trying to solve for the past two days, is that the proxy is not even attempting to reach the backend. I've been running wireshark to debug since I can't reliably access dev tools in a selenium controlled browser. The proxy receives a request to /api/*, and then returns 504 gateway timeout without even trying to access the backend. There's no [SYN] packet or anything. Does anyone have experience with an issue like this? If you could even just point me in the right direction it would be greatly appreciated.