我正在尝试使用 Backbone.js 模型来访问 Neo4j 内容。我不明白为什么以下通信未通过跨域检查:
首先是 OPTIONS 请求:
Request URL:http://localhost:7474/db/data/cypher
Request Method:OPTIONS
Status Code:204 No Content
Request Headers
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:origin, content-type, accept
Access-Control-Request-Method:POST
Connection:keep-alive
Host:localhost:7474
Origin:http://localhost:3000
Referer:http://localhost:3000/test/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
Response Headers
Access-Control-Allow-Headers:origin, content-type, accept
Access-Control-Allow-Methods:POST
Access-Control-Allow-Origin:*
Allow:OPTIONS,POST
Server:Jetty(6.1.25)
然后是 POST 请求:
Request URL:http://localhost:7474/db/data/cypher
Request Headers
Accept:application/json, text/javascript, */*; q=0.01
Content-Type:application/json
Origin:http://localhost:3000
Referer:http://localhost:3000/test/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
Request Payload
start n=node(0) match n-[:hasClass]->c where c.className=Collection return c
我得到控制台错误:
OPTIONS http://localhost:7474/db/data/cypher 204 (No Content) jquery-1.7.2.min.js:4
XMLHttpRequest cannot load http://localhost:7474/db/data/cypher. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
据我所知,该请求应该被允许,因为预检请求说 Access-Control-Allow-Origin: *. 有什么建议么?有什么我想念的吗?谢谢!