-1

Folks, I am an having this issue below, when I tested locally both angularjs and C# webapi, worked perfectly, after the deploy on the server, it doesn't work anymore.

The Interest point is I do have another page, which points to the same server, basically, I made a copy of this working feature and just updated the values, I've checked the files closely to check if the main methods were changed and they were not.

Note: Yes, CORS is already enabled and I tried a lot of different configurations

Does anyone have an Idea what this can be?

POST 504 (GATEWAY_TIMEOUT)

(index):1 Failed to load [URL_ENDPOINT_C#_WEBAPI] No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin [ANGULAR_WEBSITE] is therefore not allowed access. The response had HTTP status code 504.

EDIT: Forgot to mention we do have on web.config:

 <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Authorization, Accept, X-Requested-With" />
        <add name="Access-Control-Allow-Methods" value="OPTIONS, TRACE, GET, HEAD, POST, PUT" />
      </customHeaders>

and on our WebApiConfig.cs on the Register Method

config.EnableCors();
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Pelissonik
  • 31
  • 1
  • 1
  • 5
  • The errors msg implies that your cors config is not working, post your config code – fuzzybear Feb 28 '18 at 23:39
  • We had implemented just the config.EnableCors(), the weird point is that we have another angular page on the very same origin performing requests to the very same server – Pelissonik Feb 28 '18 at 23:58
  • Can you post a full set of request/response headers for your failing POST request? Basically, if they show that there is no A-C-A-O response header, then maybe your code to add headers is incorrect. – roryhewitt Mar 02 '18 at 01:12

2 Answers2

0

If you're getting a 504 Gateway Timeout, then your app is somehow not responding. Since the 504 response is just a basic error returned by the web server, it won't include all the CORS headers you've explicitly added, so you'll see the CORS error message.

As soon as you resolve the underlying cause of the 504 error, you'll see the CORS headers in the response.

roryhewitt
  • 4,097
  • 3
  • 27
  • 33
0

Well, I've figured out what happened, there were a method throwing an exception then I was seeing a CORS exception. So I did change this method to and then no more exception.

Thank you all

Pelissonik
  • 31
  • 1
  • 1
  • 5