🔒 CORS configuration in docker-compose and Express

This commit is contained in:
2021-10-18 12:11:30 -07:00
parent 8b3743fe6b
commit 2d1ccf7264
5 changed files with 14 additions and 21 deletions

View File

@@ -12,8 +12,6 @@ services:
- "8050:8050"
- "3050:3050"
- "8051:8051"
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- rabbitmq
- db
@@ -32,8 +30,6 @@ services:
container_name: comicvine-api
ports:
- "3080:3080"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
SERVICES: api
env_file: ./docker-env/comicvine-service.env
@@ -50,8 +46,6 @@ services:
network: host
image: frishi/comicvine-service
container_name: comicvine-service
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
SERVICES: comicvine
volumes:
@@ -66,8 +60,6 @@ services:
network: host
image: frishi/threetwo-import-service
container_name: threetwo-import-api
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "3000:3000"
environment:
@@ -88,8 +80,6 @@ services:
network: host
image: frishi/threetwo-import-service
container_name: import
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- db
- nats
@@ -108,8 +98,6 @@ services:
network: host
image: frishi/threetwo-import-service
container_name: image-transformation
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./userdata:/threetwo-import-service/userdata
- ./comics:/threetwo-import-service/comics
@@ -141,8 +129,6 @@ services:
nginx:
image: nginx
container_name: reverse-proxy
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "80:80"
volumes:

View File

@@ -40,6 +40,7 @@
"compromise-dates": "^2.2.1",
"compromise-numbers": "^1.4.0",
"compromise-sentences": "^0.3.0",
"cors": "^2.8.5",
"dayjs": "^1.10.6",
"ellipsize": "^0.1.0",
"express": "^4.17.1",

View File

@@ -1,23 +1,22 @@
server {
listen 8050;
location / {
proxy_pass http://host.docker.internal:8050;
proxy_pass http://localhost:8050;
}
}
server {
listen 3080;
location /comicvine-service {
proxy_pass http://host.docker.internal:3080;
proxy_pass http://localhost:3080;
}
}
server {
listen 3000;
location /import {
proxy_pass http://host.docker.internal:3000;
location /import-service {
proxy_pass http://localhost:3000;
}
}

View File

@@ -3,13 +3,20 @@ import bodyParser from "body-parser";
import { createServer } from "http";
import { Server } from "socket.io";
import router from "./route";
import cors from "cors";
const amqp = require("amqplib/callback_api");
// call express
const app: Express = express(); // define our app using express
app.use(cors({ origin: "*" }));
const httpServer = createServer();
export const io = new Server(httpServer, {});
export const io = new Server(httpServer, {
cors: {
origin: "*",
methods: ["GET", "POST"],
}
});
// configure app to use bodyParser for
// Getting data from body of requests

View File

@@ -4151,7 +4151,7 @@ core-util-is@~1.0.0:
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85"
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==
cors@~2.8.5:
cors@^2.8.5, cors@~2.8.5:
version "2.8.5"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==