Skip to content

Commit 2e5ccac

Browse files
authored
fix(logger-plugin): fix next.js url logging (baseUrl not supported) (chimurai#771)
1 parent 2d28db7 commit 2e5ccac

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/plugins/default/logger-plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export const loggerPlugin: Plugin = (proxyServer, options) => {
2424
*/
2525
proxyServer.on('proxyRes', (proxyRes: any, req: any, res) => {
2626
// BrowserSync uses req.originalUrl
27-
const originalUrl = req.originalUrl ?? `${req.baseUrl}${req.path}`;
27+
// Next.js doesn't have req.baseUrl
28+
const originalUrl = req.originalUrl ?? `${req.baseUrl || ''}${req.url}`;
2829
const exchange = `[HPM] ${req.method} ${originalUrl} -> ${proxyRes.req.protocol}//${proxyRes.req.host}${proxyRes.req.path} [${proxyRes.statusCode}]`;
2930
logger.info(exchange);
3031
});

0 commit comments

Comments
 (0)