Skip to content

Commit bed15a1

Browse files
committed
perf: reduce bundle size by another 18 bytes
1 parent 5f78f44 commit bed15a1

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# cors-edge
22

3-
You are writing a very simple functions that runs on edge (either on Cloudflare Workers, Fastly Edge Compute, Vercel Edge Functions, etc.) consisting of less than 100 lines of code. You want to enable CORS (Cross-Origin Resource Sharing) for your endpoint but you do not want to pull in a heavy framework with middlewares just for that. This platform-agnostic package provides a simple way to add CORS support with minimal footprint (with only `908 bytes` added to your bundle).
3+
You are writing a very simple functions that runs on edge (either on Cloudflare Workers, Fastly Edge Compute, Vercel Edge Functions, etc.) consisting of less than 100 lines of code. You want to enable CORS (Cross-Origin Resource Sharing) for your endpoint but you do not want to pull in a heavy framework with middlewares just for that. This platform-agnostic package provides a simple way to add CORS support with minimal footprint (with only `890 bytes` added to your bundle).
44

55
## Installation
66

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const createCors = ({
8787
return async (request: Request, response: Response): Promise<Response> => {
8888
const originHeaderValue = getHeader(request, ORIGIN) || '';
8989
let allowOrigin = findAllowOrigin(originHeaderValue);
90-
if (allowOrigin && typeof allowOrigin === 'object' && 'then' in allowOrigin) {
90+
if (allowOrigin && typeof allowOrigin !== 'string') {
9191
allowOrigin = await allowOrigin;
9292
}
9393
if (allowOrigin) {
@@ -111,7 +111,7 @@ export const createCors = ({
111111
}
112112

113113
let allowMethods = findAllowMethods(originHeaderValue);
114-
if ('then' in allowMethods) {
114+
if (!isArray(allowMethods)) {
115115
allowMethods = await allowMethods;
116116
}
117117
if (allowMethods.length) {

0 commit comments

Comments
 (0)