To summarize, I have to contact an API server that I don't have control over and the providers refuse the slightest change.
I can't connect to it from my application (vue.js) because of CORS error.
So I decide to use http-proxy-middleware to make a proxy and solve the problems.
When I test locally it works perfectly.
My application (localhost:8085) contacts my proxy server (localhost:5001) which contacts the API server (xxxxx.com/api/v1/x/x/x).
When I deploy in production, it doesn't work
I deploy my proxy on a windows server under IIS with a simple reverse proxy.
And there, it's the drama, the OPTIONS requests return 204 and the others return 500 with inside, the correct result of my request AND the error message.
I don't understand at all how this can happen and I can't find any more help.
Here is the proxy code :
const express = require('express');
const morgan = require('morgan');
const cors = require('cors');
require('dotenv').config();
const app = express();
app.use(morgan('dev'));
app.use(cors());
const { createProxyMiddleware } = require('http-proxy-middleware');
// Proxy endpoints
app.use('**', createProxyMiddleware({
target: "https://extranet.occicom.fr/api/voip/v1/",
changeOrigin: true,ws: false,
logLevel: "debug"
}));
module.exports = app;
And here is my IIS configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:5001/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Here is the 500 OK/NOK result :
Your expertise will be greatly appreciated !
UPDATE
When i use the proxy without IIS, it's work. But i don't know why IIS break this.