Reputation: 197
Hi i have a problem with my facebook app. When i start it after the authentcation it gives me this error :
XMLHttpRequest cannot load http: //localhost:8000/informations. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http: //localhost:8080' is therefore not allowed access. :8080/carRandomizer:1
XMLHttpRequest cannot load http: //localhost:8000/rand. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http: //localhost:8080' is therefore not allowed access.
So i understand that is a CORS problem, i already tryed to follow the official docs http://hapijs.com/api#serverrouteoptions and now i set on my server.js file this:
server.connection({ port: process.env.PORT, routes: { cors: true } });
and now i have the same error:
XMLHttpRequest cannot load https: //www.facebook.com/v2.3/dialog/oauth?client_id=1463042613952341&respo…k&state=URaCt6cXqf_JzJYgS9KlwM&scope=public_profile%2Cuser_friends%2Cemail. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. angular.js:12330 (anonymous function) @ angular.js:12330(anonymous function) @ app.js:817(anonymous function) @ angular.js:14567a.$get.n.$eval @ angular.js:15846a.$get.n.$digest @ angular.js:15657a.$get.n.$apply @ angular.js:15951l @ angular.js:10364F @ angular.js:10536e @ angular.js:10487 :8080/carRandomizer:1 XMLHttpRequest cannot load https: //www.facebook.com/v2.3/dialog/oauth?client_id=1463042613952341&respo…k&state=j-vSbeB6rGvEi_cgu-9TrM&scope=public_profile%2Cuser_friends%2Cemail. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
finally i also tryed to set the hanlder for the
http: //localhost:8000/rand
the response header this but nothing changes.
Upvotes: 1
Views: 1692
Reputation: 8571
Try specifying origin: ['*']
in the route configuration:
server.connection({ port: process.env.PORT, routes: { cors: { origin: ['*'] } } });
It looks like hapi is not picking up your connection options.
Upvotes: 2
Reputation: 31
your server-side may have a white list includes all the domains maybe you need to add your domain into the white list of server-side's cors. thanks.
Upvotes: 0