Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
Hapi not adding cors header

Hapi not adding cors header in response even after adding Access-Control-Allow-Origin: *

routes.js

const routes = [
    {
        method: 'get',
        path: '/',
        handler: (request, hapi) => {
            const response = hapi.response({
                status: 'success',
            })

            return response
        },
    },
]

module.exports = routes

server.js

const Hapi = require('@hapi/hapi')
const routes = require('./routes')

const init = async () => {
    const server = Hapi.server({
        port: 5000,
        host: 'localhost',
        routes: {
            cors: true,
        },
    })

    await server.start()

    server.route(routes)
}

init()

Response header

hapi not add Access-Control-Allow-Origin: * in response header

browser

Access to fetch at 'http://localhost:5000/notes' from origin 'url' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space local.

I add

response.header('Access-Control-Allow-Origin', '*')

still no cors header in response header

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!