2

Using angularjs to write data in another machine's file failed:

No 'Access-Control-Allow-Origin' header is present on the requested resource

Setting:

anjular js client:

$http.post(url, settingData)

rest server side:

    return Response.status(200).entity(jsonObject.toString())
            .header("Access-Control-Allow-Origin", "*")
            .header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
            .allow("OPTIONS")
            .build();

enter image description here

Luka Kerr
  • 4,161
  • 7
  • 39
  • 50
wave
  • 61
  • 3
  • 1
    Please check http://stackoverflow.com/questions/19821753/jquery-xml-error-no-access-control-allow-origin-header-is-present-on-the-req and http://stackoverflow.com/a/20973800/218152 – SwiftArchitect Jan 15 '16 at 08:07
  • I am not very understanding, could you give me the detail information setting? – wave Jan 15 '16 at 08:33
  • please dump the contents of your browsers NET tab to show request and response (if any) details – danday74 Jan 15 '16 at 10:39
  • 1
    Don't set the CORS headers in the resource method. [Use a filter](http://stackoverflow.com/a/34412067/2587435). The resource method is never hit because it is designed for POST request, while the preflight is an OPTIONS request. – Paul Samsotha Jan 15 '16 at 12:56
  • could you add what server are you using? for example, apache, nodejs + epxress, etc. This is a CORS problem and the solution should be made on the server side. for NodeJS+express you can use [this solution](http://stackoverflow.com/questions/18310394/no-access-control-allow-origin-node-apache-port-issue) from @jvandemo – Pablo Ezequiel Inchausti Mar 03 '17 at 02:34

0 Answers0