cant connect to my api

时间:2016-08-31 18:13:11

标签: java api server

I've created api and when im trying to connect to it from another machine to create admin panel that uses the api, i get this error

XMLHTTPRequest cannot load http://example.com/api/webapi/client/. No 'Access-Control-Allow-Origin' header is present on the requested source. Origin 'http://lumino.dev' is therefore not allowed access.

even tho I have this code in my resource class:

headers.getRequestHeaders().putSingle("Access-Control-Allow-Origin", "*");
        headers.getRequestHeaders().putSingle("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, HEAD");
        headers.getRequestHeaders().putSingle("Access-Control-Allow-Headers", "X-PINGOTHER, Origin, X-Requested-With, Content-Type, Accept");
        headers.getRequestHeaders().putSingle("Access-Control-Max-Age", "1728000");

I've built the api based on jersey-quickstart-webapp archetype, and im using tomcat server. what can be done?

0 个答案:

没有答案