Closed lljxx1 closed 1 year ago
Are you calling next()
in your authMiddleware
?
Example:
router.use(({ req, res, next }) => {
res.headers.set('X-Global-Middlewares', 'true')
next()
})
Also in your exammple you need to await env.KV.get("test")
since it returns a promise.
Are you calling
next()
in yourauthMiddleware
?Example:
router.use(({ req, res, next }) => { res.headers.set('X-Global-Middlewares', 'true') next() })
yeah, I did
Also in your exammple you need to await
env.KV.get("test")
since it returns a promise.
yes. I have used await
in my code. sorry for the demo
router.use({ req, res, next }) => {
if (!req.query.api_key) {
req.body = {
error: "key missing"
}
return;
}
next()
});
router.get("/check", async ({ env, req, res }) => {
console.log(env.KV)
console.log(await env.KV.get("test"))
})
env.KV
is not undefined. just call get
and will return nothing.
after a lot of bugging, if I comment router.use
part. it will work.
@tsndr hey, have checked this issue by any chance? I still believe there have some problems here
When remove this, It's worked