Answer a question

Hello everyone I'm working on a project that uses nuxt js and I'm just new to this framework. I've configured it to use spa mode, fyi I did not change or add anything in my nuxt config just the default. And below is how I've setup my pages.

pages/users/index.vue - shows list or users

pages/users/_id.vue - show specific user

I've deployed my project using npm run build and npm run start command. The dist directory is then hosted in a nginx server.

The issue is that when i navigate to /user/id using nuxt link the page is rendered properly, but when I access the page url directly or refresh the page I get nginx 404 page not found.

I've read about nuxt generate to generate pre rendered pages but is this good to use when dealing on hundreds of records?

Any help, advice, would be much appriciated.

Thanks

Answers

You are totally mixed things. First, default mode is universal aka ssr, not spa. Docs

Second, running npm run start needed for universal mode, while in spa mode you just put single html file and route ALL reuqest from nginx to this file.

But if u are using npm run start its a universal app, and u dont host simple html via your nginx, you should setup downstream source for nginx and route all request to node server e.g. default is localhost:3000

Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐