From d56050984e83eb1124d03a84def43064e9f0f1fb Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Thu, 17 Mar 2022 15:04:16 -0300 Subject: [PATCH] fix: return cors header --- Dockerfile | 13 +++++++++++++ src/api/app.js | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aa534df --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node + +COPY . /app + +WORKDIR /app + +RUN npm install + +ENV PORT=80 + +EXPOSE 80 + +CMD ["npm", "start"] \ No newline at end of file diff --git a/src/api/app.js b/src/api/app.js index d7e7a62..954e197 100644 --- a/src/api/app.js +++ b/src/api/app.js @@ -5,8 +5,12 @@ const errorMiddleware = require('../middlewares/error'); const app = express(); -app.get('/users', rescue(UserController)); +app.use((req, res, next) => { + res.setHeader('Access-Control-Allow-Origin', '*'); + next(); +}) +app.get('/users', rescue(UserController)); app.use(errorMiddleware); module.exports = app;