Skip to content

Commit

Permalink
fix(logger-plugin): fix next.js url logging (baseUrl not supported) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai committed Apr 23, 2022
1 parent 2d28db7 commit 2e5ccac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugins/default/logger-plugin.ts
Expand Up @@ -24,7 +24,8 @@ export const loggerPlugin: Plugin = (proxyServer, options) => {
*/
proxyServer.on('proxyRes', (proxyRes: any, req: any, res) => {
// BrowserSync uses req.originalUrl
const originalUrl = req.originalUrl ?? `${req.baseUrl}${req.path}`;
// Next.js doesn't have req.baseUrl
const originalUrl = req.originalUrl ?? `${req.baseUrl || ''}${req.url}`;
const exchange = `[HPM] ${req.method} ${originalUrl} -> ${proxyRes.req.protocol}//${proxyRes.req.host}${proxyRes.req.path} [${proxyRes.statusCode}]`;
logger.info(exchange);
});
Expand Down

0 comments on commit 2e5ccac

Please sign in to comment.