1

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 :

green the OK result and red the 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.

Enzo B.
  • 2,341
  • 1
  • 11
  • 33
  • You might use FRT to learn more https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis However, the 500 error message ("Something went wrong") is not generated by IIS so too early to conclude that "IIS break this". – Lex Li Aug 24 '21 at 14:32
  • Yes you are right, I meant that this is the message that the API returns to me in case of an error and it is strange to have it also in the return with the correct result JSON. Nevertheless, I ran the project on a linux without any problem that's why I think the problem comes from IIS. I'll look at your solution thanks – Enzo B. Aug 24 '21 at 14:36
  • Could please check if there is any limits such as ip address limit or firewall in the API server side which my prevent the request from your IIS server ? – Hury Shen Aug 25 '21 at 02:46
  • There is no limitation and my ip is not blacklisted – Enzo B. Aug 25 '21 at 11:27
  • You can create a support ticket on [this page](https://support.microsoft.com/) to ask microsoft engineer for help about this problem. – Hury Shen Aug 27 '21 at 05:21

0 Answers0