"Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response."
My connection config was using the cors: { origin: [] } approach to allow specific hosts when I upgrade to Hapi 11. I got some CORS errors (as I expected given the breaking changes for 11), but I continue to get this error even when using defaults ( cors: true ) and even the following which explictly providers headers to be allowed. This only seems to be happening with some of my calls though and it appears to be the cases where OPTIONS is being used.
The response header does no include access-control-allow-headers, but does include access-control-expose-headers and access-control-allow-origin (which is set to my calling hostname so the wildcard seems to be working).
Am I missing something still? Shouldn't access-control-allow-headers be included?
cors: {
origin: [ '*' ],
headers: ['Authorization', 'Content-Type', 'If-None-Match']
}
Console log here: https://github.com/hapijs/hapi/blob/master/lib/cors.js#L131
And let me know if that gives a clue.
If not today, I will be sure to look into this tomorrow.
Recent fixes should over this.
Simply posting as follows with angular js ....
var config = { method: 'POST', url: this.url + 'basic', data: {username: 'U', password: 'P'} } this.http(config).then(function(response){ console.log(response); });
To the following hapijs route....
method: ['POST','OPTIONS'],
path: '/basic',
handler: function(req, reply){
reply('ok good to go');
},
config: {
cors: true
}
Of course, the google browser starts with request method 'OPTION' but always getting this error "Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response."
What am I doing wrong?
Same error here.
+1
+1
+1
If you have an issue, open a new one with full details showing how to reproduce it. Posting +1 is only going to make me less likely to help you out.