Adding headers in Hapi.js

209 views
Skip to first unread message

ritu Kumari

unread,
Dec 8, 2015, 11:44:45 AM12/8/15
to nodejs
Hi,

I want to add  header in Hapi.js. Actually I am getting the data from mongoldb and was able to send the ajax request. But it is giving me the error that  a header is missing. in the browser console. 

Error: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I am able to get the response in POSTMAN. But not able to get in the browser.

Here is the server.js file:


Somebody pls hlp.

Thanks 

Robert Zehnder

unread,
Dec 8, 2015, 1:15:03 PM12/8/15
to nodejs
Doing some quick googling:

I fixed the notes. It's server.connection({ routes: { cors: true } }).

Or perhaps this one:

new Hapi.Server({
  connections: {
    routes: {
      cors: true
    }
  }
})

To be clear, I haven't use Hapi, just trying to find solutions

Goga Moga

unread,
Feb 11, 2016, 1:15:37 PM2/11/16
to nodejs
Reply all
Reply to author
Forward
0 new messages