{"action":"closed","issue":{"url":"https://api.github.com/repos/odewahn/react-golang-auth/issues/1","repository_url":"https://api.github.com/repos/odewahn/react-golang-auth","labels_url":"https://api.github.com/repos/odewahn/react-golang-auth/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/odewahn/react-golang-auth/issues/1/comments","events_url":"https://api.github.com/repos/odewahn/react-golang-auth/issues/1/events","html_url":"https://github.com/odewahn/react-golang-auth/issues/1","id":143234582,"number":1,"title":"Fix CORS when sending headers","user":{"login":"odewahn","id":668868,"avatar_url":"https://avatars.githubusercontent.com/u/668868?v=3","gravatar_id":"","url":"https://api.github.com/users/odewahn","html_url":"https://github.com/odewahn","followers_url":"https://api.github.com/users/odewahn/followers","following_url":"https://api.github.com/users/odewahn/following{/other_user}","gists_url":"https://api.github.com/users/odewahn/gists{/gist_id}","starred_url":"https://api.github.com/users/odewahn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odewahn/subscriptions","organizations_url":"https://api.github.com/users/odewahn/orgs","repos_url":"https://api.github.com/users/odewahn/repos","events_url":"https://api.github.com/users/odewahn/events{/privacy}","received_events_url":"https://api.github.com/users/odewahn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-24T12:44:12Z","updated_at":"2016-03-24T19:04:06Z","closed_at":"2016-03-24T19:04:05Z","body":"I want to post an auth token in the header of this call:\r\n\r\nhttps://github.com/odewahn/react-golang-auth/blob/master/src/state/user.js#L44-L61\r\n\r\n```\r\n// Deletes the container record at the given index\r\nexport function login(creds) {\r\n  console.log(creds)\r\n  var request = {\r\n    method: 'POST',\r\n    body: JSON.stringify(creds),\r\n    headers: {\r\n      \"x-authentication\": \"myLittleSecret\"\r\n    }\r\n  }\r\n  return dispatch => {\r\n    fetch(\"http://localhost:3000/login\", request)\r\n      .then( response => response.json())\r\n      .then( json => {\r\n        console.log(\"data is posted\", json)\r\n      })\r\n  }\r\n}\r\n```\r\n\r\nI'm then posting it to this handler:\r\n\r\nhttps://github.com/odewahn/react-golang-auth/blob/master/backend/handler/handler.go#L46-L70\r\n\r\nWhen I remove the headers from the JS call (the first code snippet), this works fine, but when I add in the header I want to send, I get a CORS error:\r\n\r\n```\r\nFetch API cannot load http://localhost:3000/login. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. The response had HTTP status code 404. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.\r\n```\r\n\r\nHere it is in the error console:\r\n\r\n![screen shot 2016-03-24 at 8 27 59 am](https://cloud.githubusercontent.com/assets/668868/14017197/304b0fc8-f19c-11e5-8e95-86d6465763f3.png)\r\n\r\n\r\n"}}