最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

nuxt.js - Nuxt SSR not working properly with PM2 in Ubuntu - Stack Overflow

programmeradmin2浏览0评论

Suddenly my nuxt project which running in ubuntu with nginx doesn't work propertly with SSR

  • Operating System: Linux
  • Node Version: v20.18.0
  • Nuxt Version: 3.15.4
  • CLI Version: 3.21.1
  • Nitro Version: 2.10.4
  • Package Manager: [email protected]
  • Builder: -
  • User Config: ssr, experimental, app, runtimeConfig, compatibilityDate, css, devtools, sourcemap, plugins, modules, i18n, image, fontawesome
  • Runtime Modules: @nuxtjs/[email protected], @nuxtjs/[email protected], @vesp/[email protected], @nuxtjs/[email protected], @nuxt/[email protected]
  • Build Modules: -

All the request processed on client, my nuxt.config.ts already has ssr true, here the sample what i tried to do

const {
  data: destinationData,
  isFetching: isLoading,
  error,
} = useFetch(`${baseURL}/v2/contents/destinations/${route.params.id}/${locale.value}`, { server: true, transform: (response) => response.data });

destinationData.value // will return null and the request is logged in browser network

im running the project on pm2, already try forking the instance but not found any working solution.

[PM2] Applying action restartProcessId on app [******-website](ids:

[ 0 ]) [PM2] ******-website ✓ [PM2] Process successfully

started

any information or similiar issue will help.

EDIT: trying to deploy in apache2 having similiar issue

here my ecosystem.config.cjs

module.exports = {
  apps: [{
    name: '*****-website',
    cwd: '/var/www/*****-website',
    script: '.output/server/index.mjs',
    env: {
      HOST: '0.0.0.0',
      PORT: 3000,
      NODE_ENV: 'production'
    },
    instances: 1,
    exec_mode: 'fork',
    max_memory_restart: '250M',
    watch: false,
    ignore_watch: [
      "node_modules",
      "*.log"
    ],
    autorestart: true,
    merge_logs: true,
    log_date_format: 'YYYY-MM-DD HH:mm:ss',
  }]
}

EDIT 2

i tested this on local npm run dev // fully working with SSR node .output/server/index.mjs // SSR not working at all

发布评论

评论列表(0)

  1. 暂无评论