- Koa: For Koa.js, use the
@koa/cors
package:
const Koa = require('koa'); const cors = require('@koa/cors'); const app = new Koa(); app.use(cors());
- Hapi: For Hapi.js, configure CORS in the server options:
const Hapi = require('@hapi/hapi'); const server = Hapi.server({ port: 3000, host: 'localhost', routes: { cors: { origin: ['http://example.com'], headers: ['Accept', 'Authorization', 'Content-Type'], credentials: true, }, }, });
Leave a Reply