CORS issues with vue/node to rack/thin via nginx - vuejs2

I had this working properly and all of a sudden during a restart stopped working and I can't get to the bottom of what happened.
Basically, vue/node (dev) mode is using http but the ajax uses https to the server.
Server responds with all headers including Access-Control-Request-Origin and I can see json data response from the server in the firefox dev tools
But for some reason it throws an Error: Network Error alert. Inspecting in dev tools I find
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://r.roller.lan/workstations?session_token=2de63puojmt3ubkfp94c3ohm45. (Reason: CORS header “Access-Control-Allow-Origin” does not match “https://devv.roller.lan:8080”)
I am making request from http://devv.roller.lan:8080 and somewhere in the chain gets translated to https:// which doesn't match?
Thanks

Everything works as expected after I added highlighted portion from the Nginx Reverse Proxy article Koshux referenced to the nginx conf.

Related

The CGI application did not return a valid set of HTTP errors. 502.3 - Bad Gateway: Forwarder Connection Error (ARR) on Azure ASP.NET Core App

All of a sudden we are seeing this random error / exception in our web application.
Failed to load resource: the server responded with a status of 502 (Bad Gateway).
In the Log Stream, we are seeing the following details, with specific error code as 502.3 - Bad Gateway: Forwarder Connection Error (ARR).
Also, sometimes in the browser itself we see "The CGI application did not return a valid set of HTTP errors." getting displayed.
Most of the searches for these error codes refer to "IIS / Proxy Server" configuration. But, we haven't changed any such settings.
The error happens very randomly and not specific to any user action/function. Same functionality works first and on second execution immediately after first one throws this error.
How to figure out what is causing this and how to fix?
I google this question, because the program was normal at the beginning, and the subsequent 502.3 error. After I checked the information on the Internet, I feel that it can only give us an inspiration, and it cannot solve your problem immediately.
So my suggestion is that first you browse post1 and post2 I provided.
Next, proceed to Troubleshoot according to the steps of the official documentation. Specific errors require specific analysis.

Spartacus - Error occurred while trying to proxy request

when doing yarn start in spartacus application at localhost , I am getting following error:
[HPM] Error occurred while trying to proxy request /rest/v2/electronics-spa/cms/pages?fields=DEFAULT&pageType=ContentPage&pageLabelOrId=homepage&lang=en&curr=USD from localhost:4200 to https://localhost:
9002 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
I have pretty standard proxy.bankend.js file. Any suggestions what i can investigate ?
I already tested backend is reachable via url directly.
Regards,
Archit
I am familiar with this situation. Usualy this error happens when the endpoint I an trying to proxy to is not reachable.
Looking at the error I can see your request is still going to https://localhost:9002 so I believe it's possible your proxy might not be picked up.
You should make sure that you specified the proxy config correctly. It can be done in your package.json by modifying the start script: "start": " ng serve --proxy-config proxy/proxy.backend.js", (in this case my proxy is in a proxy folder).
Hope this helps!

FineUploader Exception : XhrReadyState=0 and XhrResponseStatus=0

We're experiencing FineUploader exceptions with XhrReadyState=0 and XhrResponseStatus=0 on 5.4.1 in our production environment intermittently across browsers. We've checked out our CORS configuration for our S3 bucket and we do have the wild card origin header set.
Access-Control-Allow-Origin: *
Was looking at FineUploader CORS selectively working, and we do not set the sendCredentials value in our configuration.
Error from fine uploader is
XHR returned response code 0
The XHR response object contains the following values,
XhrReadyState=0
XhrResponseText=empty
XhrResponseType=empty
XhrResponseStatus=0
XhrTimeout=0
XhrAllResponseHeaders=empty
Update 1
So we captured a repro of this. It looks like one of our OPTIONS requests is getting a 403 randomly in the middle of the upload.
[Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (a7db116d-26ec-4b45-9566-8697d42a7b4c.VOB, line 0)
[Error] Failed to load resource: Origin http://www.ourdomain.com is not allowed by Access-Control-Allow-Origin. (a7db116d-26ec-4b45-9566-8697d42a7b4c.VOB, line 0)
[Error] XMLHttpRequest cannot load http://ourbucket.s3.amazonaws.com/....
Origin http://www.ourdomain.com is not allowed by Access-Control-Allow-Origin.
Here is the screen grab from the Safari console. I was suspecting a network problem, but I wouldn't expect such a quick 403 response if a network issue was . Also, previous OPTIONS requests had just succeeded before and after the one that 403'd. We have configured CORS on our S3 bucket.
Status 0 indicates some issue either with your server or with the network. More specifically, it indicates that the response received was completely empty. This can be caused by CORS issues or even a temporary network issue. You'll want to examine these possibilities further in order to determine what is causing the issue for you.

How can you include http://foo.local in CORS Access-Control-Allow-Origin?

I'm using *, but apparently that's not enough. I'm trying to upload a file from a client browser. It works when the client's URL is localhost:3000 or foo.com. It's not working when the URL is http://meteor.local. I've tried changing the third line to <AllowedOrigin>http://meteor.local</AllowedOrigin>, but get the same error.
The browser error:
The error text was misleading – error was not due to the header sent by s3. Adding an access rule to Cordova fixed it. (In meteor, add it with App.accessRule('http://meteor.local'); in mobile-config.js.)

Play 2.1.0 + Apache 2.2 Reverse proxy => 502 proxy error when idle

Config
We have a play 2.1.0 with angularjs setup in a production mode.
We have reverse proxy load balancer setup with apache 2.2 something like mentioned in here
http://www.playframework.com/documentation/2.1.0/HTTPServer
This whole app is running in an iframe inside navigated from a jboss application.
Problem
Most of the time it works and sometimes when the connection is left idle for 2/3 hours, untouched, no one hit the reverse proxy url to load the jboss/play, then we are getting the 502 proxy error in the iframe content after a few mins wait.
Play receives the request, but somehow decides not to respond at all. This occurs only for the first time or couple of time after the wakeup. Then when we refresh the page play receives the request and responds it properly.
Tried
We get a tcpdump on the play port and it we have got all the requests being received, but no response sent from play for the failed scenario. Whereas the same request got responded by play subsequent times.
X-Forwarded-For: ,X-Forwarded-Host: X-Forwarded-Server: .. Connection: Keep-Alive - all these headers are being sent in the lost response tcpdump.
Tried KeepAlive, with timeouts in the proxy server, not much help. Why the play didn't respond for the initial connections after idle state, is there any conf we can set to keep it alive?
Workaround
Polling the play server url constantly every half an hour from the same server makes this issue not reproducible.
Still any help/suggestions would be really appreciated to fix this issue..
I tried to solve this problem myself. Approaches like the answers mentioned here and here did not change anything.
I then decided to go for nginx again which I have been using with Play applications before. The setup is to be found here. Since then the problem is gone.