未设置访问控制允许起源头

时间:2018-06-29 08:54:12

标签: cors hapi.js

我正在尝试在我的api路由上启用cors:

const server = Hapi.server({
  port: 3003,
  host: 'localhost',
  routes: {
    log: {
      collect: true
    },
    cors: {
      origin: ['http://localhost:8080'],
      additionalHeaders: ['accept-language', 'accept-encoding', 'connection', 'origin', 'host', 'user-Agent', 'access-control-request-headers']
    }
  }
});

我添加了其他标头,但它不会触发“ Access-control-allow-origin标头”的设置。

以下是请求标头:

 host: 'localhost:3003',
  connection: 'keep-alive',
  'access-control-request-method': 'POST',
  origin: 'http://localhost:8080',
  'user-agent':
   'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36',
  'access-control-request-headers': 'x-access-token',
  accept: '*/*',
  'accept-encoding': 'gzip, deflate, br',
  'accept-language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7'

我想念什么? 谢谢。

0 个答案:

没有答案