I am using angularjs on the UI and it cant tell the difference between the server being down or a timeout both respond with something like the following. This is due to cors. When server is down or a request times out apache does not add the cors header.
"{"data":null,"status":0,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":"https://api.domain.com/containers/60539","headers":{"Accept":"application/json, text/plain, */*"}},"statusText":""}"
How can I make sure that I get the proper 502/503 statuses back from apache on the GET request while having 200 on the options?
Thank you!
Current Config:
<VirtualHost *:443>
ServerName api.domain.com
<IfModule proxy_module>
ProxyRequests Off
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
ProxyPass / 1.1.1.1
Header set Access-Control-Allow-Origin "*"
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</IfModule>
SSLEngine on
SSLCertificateFile "${WILDCARDSSLCRT}"
SSLCertificateKeyFile "${WILDCARDSSLKEY}"
SSLCertificateChainFile "${WILDCARDSSLCHAIN}"
</VirtualHost>
Instead of Header set use Header always set:
Header always set Access-Control-Allow-Origin "*"
https://httpd.apache.org/docs/current/mod/mod_headers.html#Header explains:
The table that corresponds to
alwaysis used for locally generated error responses as well as successful responses.
And a couple of guides with some good guidance:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With