HTMLをfileプロトコルで立ち上げたら以下の様なエラーに見舞われる(Chrome)
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
XHRは同一ドメインでしか通信できないので、プロトコルをあわせないといけない。忘れていました。
HTMLをfileプロトコルで立ち上げたら以下の様なエラーに見舞われる(Chrome)
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
XHRは同一ドメインでしか通信できないので、プロトコルをあわせないといけない。忘れていました。
ほんとうにただそれだけ。
$ curl -v http://localhost:9000/ok * Trying ::1... * Connected to localhost (::1) port 9000 (#0) > GET /ok HTTP/1.1 > Host: localhost:9000 > User-Agent: curl/7.43.0 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: text/plain < Date: Thu, 11 Feb 2016 12:36:59 GMT < Content-Length: 3 < * Connection #0 to host localhost left intact OK! $ curl -v http://localhost:9000/bad * Trying ::1... * Connected to localhost (::1) port 9000 (#0) > GET /bad HTTP/1.1 > Host: localhost:9000 > User-Agent: curl/7.43.0 > Accept: */* > < HTTP/1.1 400 Bad Request < Content-Type: text/plain < Date: Thu, 11 Feb 2016 12:37:26 GMT < Content-Length: 12 < * Connection #0 to host localhost left intact Bad Request! $ curl -v http://localhost:9000/error * Trying ::1... * Connected to localhost (::1) port 9000 (#0) > GET /error HTTP/1.1 > Host: localhost:9000 > User-Agent: curl/7.43.0 > Accept: */* > < HTTP/1.1 500 Internal Server Error < Content-Type: text/plain < Date: Thu, 11 Feb 2016 12:37:41 GMT < Content-Length: 22 < * Connection #0 to host localhost left intact Internal Server Error!
正直、コーディングよりコンパイルのほうに時間がかかったような気がするのです。