Skip to content

Commit 589481d

Browse files
committed
🔧 fix: static content JIT
1 parent e5c77bd commit 589481d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/compose.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ export const composeHandler = ({
11531153
c.set.redirect ||
11541154
c.set.cookie
11551155
)
1156-
return mapResponse(r, c.set, c.request)
1156+
return mapResponse(${handle}.clone(), c.set, c.request)
11571157
else
11581158
return ${handle}.clone()`
11591159
: `return ${handle}.clone()`
@@ -1202,7 +1202,7 @@ export const composeHandler = ({
12021202
c.set.redirect ||
12031203
c.set.cookie
12041204
)
1205-
return mapResponse(r, c.set, c.request)
1205+
return mapResponse(${handle}.clone(), c.set, c.request)
12061206
else
12071207
return ${handle}.clone()`
12081208
: `return ${handle}.clone()`

test/response/static.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,18 @@ describe('Static Content', () => {
8585

8686
expect(response).toBe('handled')
8787
})
88+
89+
it('clone content', async () => {
90+
const app = new Elysia().get('/', 'Static Content', {
91+
beforeHandle({ set }) {
92+
set.headers['X-Powered-By'] = 'Elysia'
93+
}
94+
})
95+
96+
await app.handle(req('/'))
97+
await app.handle(req('/'))
98+
const headers = await app.handle(req('/')).then((x) => x.headers)
99+
100+
expect(headers.get('X-Powered-By')).toBe('Elysia')
101+
})
88102
})

0 commit comments

Comments
 (0)