Skip to content

Commit 494aafd

Browse files
committed
fix: correct path syntax for Express 5.0.0
Express 5.0.x has changed how wildcard and regexp characters are used in path strings. Update server code to use the new syntax per https://expressjs.com/en/guide/migrating-5.html#path-syntax.
1 parent 9697ffe commit 494aafd

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

package-lock.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function getServer(
4444
// Express middleware
4545

4646
// Set request-specific values in the very first middleware.
47-
app.use('/*', (req, res, next) => {
47+
app.use('/{*splat}', (req, res, next) => {
4848
setLatestRes(res);
4949
res.locals.functionExecutionFinished = false;
5050
next();
@@ -136,7 +136,7 @@ export function getServer(
136136
}
137137
} else if (options.signatureType === 'http') {
138138
// We configure some default ignored routes, only for HTTP functions.
139-
app.use('/favicon.ico|/robots.txt', (req, res) => {
139+
app.use(['/favicon.ico', '/robots.txt'], (req, res) => {
140140
// Neither crawlers nor browsers attempting to pull the icon find the body
141141
// contents particularly useful, so we filter these requests out from invoking
142142
// the user's function by default.
@@ -145,7 +145,7 @@ export function getServer(
145145
}
146146

147147
if (options.signatureType === 'http') {
148-
app.use('/*', (req, res, next) => {
148+
app.use('/{*splat}', (req, res, next) => {
149149
onFinished(res, (err, res) => {
150150
res.locals.functionExecutionFinished = true;
151151
});
@@ -158,9 +158,9 @@ export function getServer(
158158
// Set up the routes for the user's function
159159
const requestHandler = wrapUserFunction(userFunction, options.signatureType);
160160
if (options.signatureType === 'http') {
161-
app.all('/*', requestHandler);
161+
app.all('/{*splat}', requestHandler);
162162
} else {
163-
app.post('/*', requestHandler);
163+
app.post('/{*splat}', requestHandler);
164164
}
165165

166166
return http.createServer(app);

0 commit comments

Comments
 (0)