How to resolve CORS ie same origin policy in angularjs

前端 未结 2 568
孤城傲影
孤城傲影 2020-12-22 10:35

I am developing a mobile application in angularjs where I have to make call to web service. But, when I am making the call with $http.get it is giving the follo

2条回答
  •  感情败类
    2020-12-22 11:09

    apache:

    http://enable-cors.org/server_apache.html

    nodejs

    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Content-Type");
    

    apache sling

    http://sling.apache.org/apidocs/sling5/org/apache/sling/api/servlets/SlingSafeMethodsServlet.html#doOptions(org.apache.sling.api.SlingHttpServletRequest,org.apache.sling.api.SlingHttpServletResponse) utilise doOptions and return Allow

    unfortunatelly I'm not an apache sling expert and that's how much i was able to google, check your network tab, the first call to your server is a 'OPTIONS' call which returns what options are allowed it should return * or specific ones like 'get' or 'post' depending on needs then the reall call will be made

提交回复
热议问题