New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tinyhttp/cors

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/cors - npm Package Compare versions

Comparing version 0.2.14 to 0.2.16

12

CHANGELOG.md
# @tinyhttp/cors
## 0.2.16
### Patch Changes
- Fix weird problems with internet that I couldn't publish normally
## 0.2.15
### Patch Changes
- Add proper sub-app support
## 0.2.14

@@ -4,0 +16,0 @@

40

dist/index.js

@@ -1,1 +0,39 @@

import{vary}from"es-vary";const cors=({origin="*",methods=["GET","HEAD","PUT","PATCH","POST","DELETE"],allowedHeaders,exposedHeaders,credentials,maxAge,optionsSuccessStatus=204})=>{return(req,res,next)=>{if(typeof origin==="boolean"&&origin===!0)res.setHeader("Access-Control-Allow-Origin","*");else if(typeof origin==="string")res.setHeader("Access-Control-Allow-Origin",origin);else if(typeof origin==="function")res.setHeader("Access-Control-Allow-Origin",origin(req,res));if(typeof origin==="string"&&origin!=="*"||typeof origin==="function")vary(res,"Origin");res.setHeader("Access-Control-Allow-Methods",methods.join(", ").toUpperCase());if(allowedHeaders)res.setHeader("Access-Control-Allow-Headers",allowedHeaders);if(exposedHeaders)res.setHeader("Access-Control-Expose-Headers",exposedHeaders);if(credentials)res.setHeader("Access-Control-Allow-Credentials","true");if(maxAge)res.setHeader("Access-Control-Max-Age",maxAge);if(next===void 0){res.statusCode=optionsSuccessStatus;res.end()}next==null?void 0:next()}};export{cors};
// src/index.ts
import {vary} from "es-vary";
const cors = ({
origin = "*",
methods = ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
allowedHeaders,
exposedHeaders,
credentials,
maxAge,
optionsSuccessStatus = 204
}) => {
return (req, res, next) => {
if (typeof origin === "boolean" && origin === true)
res.setHeader("Access-Control-Allow-Origin", "*");
else if (typeof origin === "string")
res.setHeader("Access-Control-Allow-Origin", origin);
else if (typeof origin === "function")
res.setHeader("Access-Control-Allow-Origin", origin(req, res));
if (typeof origin === "string" && origin !== "*" || typeof origin === "function")
vary(res, "Origin");
res.setHeader("Access-Control-Allow-Methods", methods.join(", ").toUpperCase());
if (allowedHeaders)
res.setHeader("Access-Control-Allow-Headers", allowedHeaders);
if (exposedHeaders)
res.setHeader("Access-Control-Expose-Headers", exposedHeaders);
if (credentials)
res.setHeader("Access-Control-Allow-Credentials", "true");
if (maxAge)
res.setHeader("Access-Control-Max-Age", maxAge);
if (next === void 0) {
res.statusCode = optionsSuccessStatus;
res.end();
}
next == null ? void 0 : next();
};
};
export {
cors
};

4

package.json
{
"name": "@tinyhttp/cors",
"version": "0.2.14",
"version": "0.2.16",
"description": "tinyhttp CORS module",

@@ -44,4 +44,4 @@ "type": "module",

"scripts": {
"build": "tsup src/index.ts --minify-whitespace --format cjs,esm --dts"
"build": "tsup src/index.ts --format cjs,esm --dts"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc