Skip to content

Commit 5e626b9

Browse files
authored
Merge pull request #31 from davemo88/not-catching-all-requests
remove wrapping arrow func to handle all requests in middleware
2 parents 895add8 + 5fe9c14 commit 5e626b9

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/index.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,23 @@ function vitePluginWasmPack(
159159
},
160160

161161
configureServer({ middlewares }) {
162-
return () => {
163-
// send 'root/pkg/xxx.wasm' file to user
164-
middlewares.use((req, res, next) => {
165-
if (isString(req.url)) {
166-
const basename = path.basename(req.url);
167-
res.setHeader(
168-
'Cache-Control',
169-
'no-cache, no-store, must-revalidate'
170-
);
171-
const entry = wasmMap.get(basename);
172-
if (basename.endsWith('.wasm') && entry) {
173-
res.writeHead(200, { 'Content-Type': 'application/wasm' });
174-
fs.createReadStream(entry.path).pipe(res);
175-
} else {
176-
next();
177-
}
162+
// send 'root/pkg/xxx.wasm' file to user
163+
middlewares.use((req, res, next) => {
164+
if (isString(req.url)) {
165+
const basename = path.basename(req.url);
166+
res.setHeader(
167+
'Cache-Control',
168+
'no-cache, no-store, must-revalidate'
169+
);
170+
const entry = wasmMap.get(basename);
171+
if (basename.endsWith('.wasm') && entry) {
172+
res.writeHead(200, { 'Content-Type': 'application/wasm' });
173+
fs.createReadStream(entry.path).pipe(res);
174+
} else {
175+
next();
178176
}
179-
});
180-
};
177+
}
178+
});
181179
},
182180

183181
buildEnd() {

0 commit comments

Comments
 (0)