Skip to content
Snippets Groups Projects
Verified Commit d9a41f4b authored by Dorian Koch's avatar Dorian Koch
Browse files

add reverse proxy to circumvent cors

parent 158dbc71
Branches
Tags v2.0.7
1 merge request!14fix layout shift, improve footer, add timetable, housekeeping
this exists because it is very annoying to deal with cors while developing
I need to deal with cors because i want to test the website on my mobile phone and tablet while running the dev server on my computer
adding the local ip to the allow cors header did not work.
services:
videoag:
image: nginx:latest
ports:
- 7000:7000
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
extra_hosts:
host.docker.internal: host-gateway
events {
worker_connections 1024;
}
http {
client_body_in_file_only off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server {
listen 7000;
location /api {
proxy_pass http://host.docker.internal:5000/api;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
proxy_pass http://host.docker.internal:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}
......@@ -80,6 +80,9 @@ export class BackendImpl {
throw new Error(
"Missing NEXT_PUBLIC_API_URL_PREFIX env variable. For development put 'NEXT_PUBLIC_API_URL_PREFIX=http://localhost:5000' into .env.local",
);
if (process.env.NEXT_PUBLIC_API_URL_PREFIX === "origin")
return window.location.origin + basePath + "/api/v0";
return process.env.NEXT_PUBLIC_API_URL_PREFIX + "/api/v0";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment