Closed hslee2008 closed 1 year ago
If this is the fix, it seems like it is what I was saying in the issue. If so, you need to call the eventHandler()
in the same place in your code you are using this middleware, not in the middleware itself like in this pull request. Pulling in the h3
module breaks the Express.js usage, whixh of course we need to support as an Express.js module.
So your code should be like
var serveStatic = require('serve-static')
var { eventHandler } = require('h3')
// various setup, until...
// when you call serveStatic then wrap that result with eventHandler
eventHandler(serveStatic(/* options */))
I will note that I used eventHandler
function above as that is what you used in your pull request. The changelog, to me, seems to indicate you need to use fromNodeMiddleware
, but I am not familiar with the framework. It may be best to open an issue against the h3
framework to help as well if you are not sure.
My understanding, and even shown in that PR you linked, is that the function passed to eventHandler
needs to be one that only takes the event
argument, not the req
, res
, next
arguments. You can see that change in the PR you link, but you didn't change it here. Since eventHandler
just returns the original function, our test suite passes still (at least on the versions not broken by importing h3
), but that doesn't show it would work in the h3
framework itself since no tests were added for that.
Related Issue
151
Test
Note
I'm not exactly sure if this would fix the problem or even if this will work because I have no experience in this field. I also have no idea how to test this in Nuxt. I took some notes from https://github.com/nuxt-modules/tailwindcss/pull/545