Skip to content

CORS Configuration

Use autoPreflight to return 204 for preflight requests and set CORS headers through staticResponseHeaders.

import Oweb from 'owebjs';
const app = await new Oweb({
uWebSocketsEnabled: true,
autoPreflight: true,
poweredByHeader: false,
staticResponseHeaders: {
'access-control-allow-origin': 'https://yourdomain.com',
'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
'access-control-allow-headers': 'Content-Type, Authorization',
vary: 'Origin',
},
}).setup();

If you need credentials, do not use * for access-control-allow-origin; set an explicit origin.