
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
Optional CORS plugin for Najm framework with global, controller-level, and route-level configuration
CORS (Cross-Origin Resource Sharing) plugin for Najm framework with support for global, controller-level, and route-level configuration.
bun add najm-cors
import { Server } from 'najm-core';
import { cors } from 'najm-cors';
new Server()
.use(cors({ origin: 'https://example.com' }))
.load(YourController)
.listen(3000);
Apply CORS settings globally to all routes:
import { Server } from 'najm-core';
import { cors } from 'najm-cors';
new Server()
.use(cors({
origin: 'https://example.com',
allowMethods: ['GET', 'POST', 'PUT', 'DELETE'],
allowHeaders: ['Content-Type', 'Authorization'],
credentials: true,
maxAge: 86400
}))
.load(Controller)
.listen(3000);
Enable CORS with default settings:
new Server()
.use(cors(true))
.load(Controller)
.listen(3000);
Override global settings for an entire controller:
import { Controller, Get } from 'najm-core';
import { Cors } from 'najm-core';
@Controller('/api')
@Cors({ origin: 'https://admin.example.com' })
export class AdminController {
@Get('/users')
getUsers() {
return { users: [] };
}
}
Override settings for specific routes:
@Controller('/api')
@Cors({ origin: 'https://admin.example.com' })
export class AdminController {
@Get('/public')
@Cors({ origin: '*' })
publicData() {
return { data: 'public' };
}
@Post('/private')
@Cors({ disabled: true })
privateData() {
return { data: 'private' };
}
}
interface CorsOptions {
origin?: string | string[]; // Origin URL(s) allowed ('*' for any)
allowMethods?: string[]; // Allowed HTTP methods
allowHeaders?: string[]; // Allowed request headers
exposeHeaders?: string[]; // Headers exposed to client
maxAge?: number; // Preflight cache time in seconds
credentials?: boolean; // Allow credentials
preflight?: boolean; // Handle preflight requests
}
{
origin: 'http://localhost:3000',
allowMethods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'],
allowHeaders: ['Content-Type', 'Authorization'],
exposeHeaders: ['Content-Type', 'Authorization'],
credentials: true,
preflight: true
}
CORS configuration is resolved in this order (highest to lowest priority):
@Cors() decorator (specific method)@Cors() decorator (all methods).use(cors(...))cors({
origin: ['https://app1.com', 'https://app2.com'],
credentials: true
})
cors({
origin: '*',
allowHeaders: ['Content-Type', 'X-Custom-Header'],
exposeHeaders: ['X-Response-Header']
})
@Controller('/public')
export class PublicController {
@Get('/data')
@Cors({ disabled: true })
publicData() {
return { data: 'public' };
}
}
The CORS plugin:
scan phaseconfigure phaseactivate phase*) with credentials: true is not recommended and will log a warningallowHeaders - only allow necessary headersMIT
FAQs
Optional CORS plugin for Najm framework with global, controller-level, and route-level configuration
The npm package najm-cors receives a total of 216 weekly downloads. As such, najm-cors popularity was classified as not popular.
We found that najm-cors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.