I have a request from my server (Angular served by NGINX) which locates the closest schools, hospital and transport from a given long and lat.
When executing the request I am getting a CORS header error on the server (see below):
Access to XMLHttpRequest at 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=long,lat&radius=500&type=school&keyword=&key=APIKey' from origin 'https://domainname.co.uk' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
The site is hosted on NGINX (Docker container) and I have amended the conf file to the below:
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location / {
add_header Access-Control-Allow-Origin *;
try_files $uri $uri/ /index.html;
}
}
}
As far as I understand the add_header line should allow Access-Control-Allow-Origin but I still keep getting the above mentioned error.
Any help is appreciated.