diff options
Diffstat (limited to 'front/src/setupProxy.js')
-rw-r--r-- | front/src/setupProxy.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/front/src/setupProxy.js b/front/src/setupProxy.js new file mode 100644 index 0000000..b23c857 --- /dev/null +++ b/front/src/setupProxy.js @@ -0,0 +1,21 @@ +const { createProxyMiddleware } = require("http-proxy-middleware"); + +module.exports = function (app) { + if (process.env.NODE_ENV != "production") { + app.use( + "/api", + createProxyMiddleware({ + target: "http://localhost:8080", + changeOrigin: true, + pathRewrite: (path, _req) => { + return path.replace("/api", ""); + }, + onProxyRes: function (proxyRes, req, res) { + proxyRes.headers["Access-Control-Allow-Origin"] = "*"; + proxyRes.headers["Access-Control-Allow-Methods"] = + "GET,PUT,POST,DELETE,PATCH,OPTIONS"; + }, + }) + ); + } +}; |