Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  55] [ 5]  / answers: 1 / hits: 27080  / 8 Years ago, sun, june 19, 2016, 12:00:00

I am working HapiJs Restful web service and trying to enable cors so any client even from different domain can consume my services. I tried cors=true in server connection object but didn't work.


More From » node.js

 Answers
14

Where did you put cors=true? Could you add some code?



Without know exactly where you've put cors = true, this bit of code may help you:



server.connection({ routes: { cors: true } })


Or try adding the allowed cors in the config section of your route.



server.route({
config: {
cors: {
origin: ['*'],
additionalHeaders: ['cache-control', 'x-requested-with']
}
},


Take a look at this question: hapi.js Cors Pre-flight not returning Access-Control-Allow-Origin header


[#61716] Thursday, June 16, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andrewb

Total Points: 259
Total Questions: 124
Total Answers: 90

Location: Ivory Coast
Member since Sun, Mar 7, 2021
3 Years ago
;