I have small java application with rest api. It's deployed and available with url like http://1.1.1.1:8080/rest
. Also I enabled CORS filter there and it works find.
But also I would like to configure access to my api with url like "http://myhost.com/". In this case CORS filter stop working.
Any ideas?
UPD1
Available headers:
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
UPD2
Updated 'Access-Control-Allow-Headers':
response.setHeader("Access-Control-Allow-Headers",
"x-requested-with, " +
"Content-Type, " +
"Host, " +
"User-Agent, " +
"Accept, " +
"Accept-Language, " +
"Accept-Encoding, " +
"Referer, " +
"Origin, " +
"Connection, " +
"Cache-Control");
Request:
GET /list HTTP/1.1
Host: myhost.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: */*
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://mysecondhost.com/test.html
Origin: http://mysecondhost.com
Connection: keep-alive
Cache-Control: max-age=0
UPD3
Looks like we have nginx there with the following headers configuration:
add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE,OPTIONS';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'WD-Since,WD-Start,WD-Direction,WD-Length,WD-Ids,Content-Type,WD-Client-Id';
add_header 'Access-Control-Expose-Headers' 'WD-Total-Length,WD-Phone-Modal,WD-Client-Id,WD-Udid,WD-Need-More';
proxy_cache off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/rest/;