Modify 404 response from REST API

Hi,

I used this API (rest-api/cdn/show_routes) to get the streams active in CDN. If the streams are active , it returns 200 response when there are no streams in CDN 404 response is returned.

The actual issues come here when I am using AWS Loadbalancer to call this API. When 200 response is returned from WCS, LB returns data with 200. But when 404 response is returned from WCS, LB returns with 502 bad gateway.

On checking with the issue, I found this discussion https://forums.aws.amazon.com/thread.jspa?threadID=94483
It seems proper HTTP headers has to be returned from source so that LB captures it properly.

Is there any way to change the reponse code or add proper HTTP headers from WCS when there is no active streams in CDN?
 

Max

Administrator
Staff member
Good day
On checking with the issue, I found this discussion https://forums.aws.amazon.com/thread.jspa?threadID=94483
It seems proper HTTP headers has to be returned from source so that LB captures it properly.
WCS returns proper HHTP headers for 404 response, for example
1593676619063.png

In the thread you mentioned there are no any recommedations about headers which should be included.
Now, we working on REST API CORS support issues in ticket WCS-2591. This will add settings to define CORS headers. Maybe it will help.
You can try to ask AWS support about this issue.
We recommend also to send REST API queries directly to the instances, not to LB, to be sure you receiving actual state.
 

Max

Administrator
Staff member
rest_access_control_headers setting has been added in WCS build 5.2.688.
E.g., for REST basic authentication CORS this can be added to WCS_HOME/conf/flashphoner.properties
Code:
rest_access_control_headers=Access-Control-Allow-Origin: <origin>;Access-Control-Allow-Credentials: true;Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS;Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
 
Top