Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
nextjs-edge-cors
Advanced tools
The easiest way to enable CORS is in your Next config, per the [docs](https://vercel.com/guides/how-to-enable-cors):
The easiest way to enable CORS is in your Next config, per the docs:
// next.config.mjs
export const headers = () => {
return [
{
source: "/api/cors/:path*",
headers: [
{ key: "Access-Control-Allow-Credentials", value: "true" },
{ key: "Access-Control-Allow-Origin", value: "*" },
{ key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
{ key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" },
]
}
];
};
Alternatively, you can use the withCors()
Middleware wrapper:
// src/middleware.ts
import { withCors } from "nextjs-edge-cors"
export const middleware = withCors();
export const config = {
matcher: ["/api/cors/:path*"]
};
You can wrap existing Middleware or pass CORS options to withCors()
:
import { withCors } from "nextjs-edge-cors"
export const middleware = withCors(
otherMiddleware,
{
/**
* Only allow CORS requests from Google.com. Comma separate for multiple
* values.
*/
origin: "https://www.google.com"
}
);
export const config = {
matcher: ["/api/cors/:path*"]
};
FAQs
The easiest way to enable CORS is in your Next config, per the [docs](https://vercel.com/guides/how-to-enable-cors):
The npm package nextjs-edge-cors receives a total of 286 weekly downloads. As such, nextjs-edge-cors popularity was classified as not popular.
We found that nextjs-edge-cors demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.