2

Hi I been trying the proxy solution to avoid the cors problems in myapp but it doesn't seem to work, i restarted my machine so many times and that made no difference. Basically myapp using fetchApi to call another domain (localhost:8080) which is a SpringBoot application endpoint. I added in package.json "proxy": "http://localhost:8080/" but the api still return calls with localhost:3000 and i tried setupProxy.js but i faced same issue....Am i missing anything else ! any help would be appreciated...

const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
  app.use(
    "/oauth",
    createProxyMiddleware({
      target: "http://localhost:8080",
      changeOrigin: true,
      secure: false,
      logLevel: "debug",
    })
  );
};
  • I'm having a similar issue. In `setupProxy.js` I have something similar to the above and get the following error: `[HPM] Error occurred while trying to proxy request /api from localhost:3000 to https://localhost:8080 (DEPTH_ZERO_SELF_SIGNED_CERT) (https://nodejs.org/api/errors.html#errors_common_system_errors)` – Matthew Knill Nov 24 '20 at 11:07
  • Just wondering how you managed to resolve this? Having the same issue. Thank you – robster Nov 26 '20 at 04:41
  • @robster I have added some cors codes in my spring boot application to fix this issue. – user13382723 Dec 13 '20 at 20:25

1 Answers1

1

I removed the {} on createProxyMiddleware and it started working. Thanks

Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62