Skip to content

Commit

Permalink
fix(fastify): Get rid of fastify deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Oct 26, 2023
1 parent 95e5132 commit 4b769c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function webpackPlugin (fastify, opts) {
const ETagCached = Symbol('ETagCached')
const ETagMatched = Symbol('ETagMatched')
fastify.addHook('onRequest', (req, rep, done) => {
if (!rep.context.config.static) return done()
if (!req.routeOptions.config.static) return done()

req.cdnUrl = req.headers['x-cdn-url'] || defaultCdnUrl
const etag = etagCache.get(`${req.cdnUrl}${req.raw.url}`)
Expand All @@ -93,7 +93,7 @@ async function webpackPlugin (fastify, opts) {
rep.header('ETag', etag)
}

if (rep.context.config.static && !rep[ETagCached]) {
if (req.routeOptions.config.static && !rep[ETagCached]) {
etagCache.set(`${req.cdnUrl}${req.raw.url}`, etag)
}
if (req.headers['if-none-match'] === etag) rep.code(304)
Expand Down

0 comments on commit 4b769c0

Please sign in to comment.