Skip to content

Commit 91bf598

Browse files
committed
fix reading request headers for elysia 1.1
1 parent afcc25a commit 91bf598

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ export const app = new Elysia()
3434
// create a store to hold cache key
3535
.state('cacheKey', '')
3636
// validate request / set cache key
37-
.onBeforeHandle({ as: 'global' }, ({ store, set, headers, path, query: { page } }) => {
37+
.onBeforeHandle({ as: 'global' }, ({ store, set, request, path, query: { page } }) => {
3838
set.headers['Content-Type'] = 'application/json'
3939

4040
// validate custom header value
41-
if (process.env.NCAA_HEADER_KEY && headers['x-ncaa-key'] !== process.env.NCAA_HEADER_KEY) {
41+
if (
42+
process.env.NCAA_HEADER_KEY &&
43+
request.headers.get('x-ncaa-key') !== process.env.NCAA_HEADER_KEY
44+
) {
4245
set.status = 401
4346
throw new Error('Unauthorized')
4447
}

0 commit comments

Comments
 (0)