Search code examples
server-side-renderingvitepnpmnuxt3.js

Nuxt 3 SSR - No console logs of server API in dev environment


When you do a simple console log in server API side, it doesn't show up when you build it using pnpm run dev.

dev environment

But if you build it using pnpm run build and run the index.mjs, the console log will show up.

Code:

export default defineEventHandler(async (event) => {
  console.log('HAHAHAHAHA');

  return 'LOGIN!';
});

Here is my npx nuxi info:

------------------------------
- Operating System: `Linux`
- Node Version:     `v18.12.1`
- Nuxt Version:     `3.0.0`
- Nitro Version:    `1.0.0`
- Package Manager:  `[email protected]`
- Builder:          `vite`
- User Config:      `app`, `runtimeConfig`, `modules`, `ssr`, `vite`, `typescript`, `css`, `build`
- Runtime Modules:  `@app/[email protected]`, `[email protected]`, `@pinia/[email protected]`
- Build Modules:    `-`
------------------------------

Solution

  • Output from console.log() from server is output in the terminal, where you run your pnpm run dev command or where the server has been started.

    Not on a client side. Not in a browser.