Closed gothub closed 4 years ago
This problem was due to a basic NGINX configuration omission. The NGINXINC virtual server reads from a k8s configMap for basic configuration items such as CORS. The fix is to add 'always' to 'add_header' directives in the configMap, for example:
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-config
namespace: nginx-ingress
data:
# Added CORS 2020 06 18
location-snippets: |
...
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '$http_origin' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Origin, Cache-Control' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
Note that all the NGINXINC virtual server configuration will be added to the github 'DataONEorg/api-ingress-k8s' repo.
When quotas are listed (
QuotasResource.listQuotas()
) or a single quota is retrieved (QuotasResource.retrieve()
) CORS headers are not returned, causing problems for JS applications which will not allow the results of the query to be accessed unless the required CORS headers are returned. For example, here is alistQuotas()
request for quotas that don't exist, causing a 404 result: