Skip to content

Commit f7059de

Browse files
committed
new release
1 parent 12f031f commit f7059de

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

spiceflow/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# spiceflow
22

3+
## 1.17.10
4+
5+
### Patch Changes
6+
7+
- Fix CORS middleware immutable headers error in Cloudflare Workers by properly handling Vary header updates on response headers instead of attempting to modify request headers
8+
39
## 1.17.9
410

511
### Patch Changes

spiceflow/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spiceflow",
3-
"version": "1.17.9",
3+
"version": "1.17.10",
44
"description": "Simple API framework with RPC and type safety",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

spiceflow/src/cors.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export const cors = (options?: CORSOptions): MiddlewareHandler => {
6363
// Suppose the server sends a response with an Access-Control-Allow-Origin value with an explicit origin (rather than the "*" wildcard).
6464
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
6565
if (opts.origin !== '*') {
66-
const existingVary = c.request.headers.get('Vary')
66+
const existingVary = responseHeaders.get('Vary')
6767

6868
if (existingVary) {
69-
set('Vary', existingVary)
69+
set('Vary', `${existingVary}, Origin`)
7070
} else {
7171
set('Vary', 'Origin')
7272
}
@@ -113,7 +113,12 @@ export const cors = (options?: CORSOptions): MiddlewareHandler => {
113113
}
114114
if (headers?.length) {
115115
set('Access-Control-Allow-Headers', headers.join(','))
116-
c.request.headers.append('Vary', 'Access-Control-Request-Headers')
116+
const existingVary = responseHeaders.get('Vary')
117+
if (existingVary) {
118+
set('Vary', `${existingVary}, Access-Control-Request-Headers`)
119+
} else {
120+
set('Vary', 'Access-Control-Request-Headers')
121+
}
117122
}
118123

119124
responseHeaders.delete('Content-Length')

0 commit comments

Comments
 (0)