Questions tagged [nuxtserverinit]
11 questions
7
votes
1 answer
How to handle Nuxt SSR errors and show custom 404 || 500 pages?
How do you handle errors when Nuxt's SSR runs into an error?
Currently i am using error() handler but it doesn't work in the production?
This is the example of my Nuxt app.
asyncData
async asyncData({ store, route, error }) {
return…

Miloslavc
- 127
- 2
- 7
5
votes
2 answers
How to Implement nuxtServerInit Action to load data from server-side on the initial load in Pinia (Nuxt3)
My Code:
export const useMenuStore = defineStore("menuStore", {
state: () => ({
menus: [],
}),
actions: {
async nuxtServerInit() {
const { body } = await…

Minh Yến
- 97
- 4
2
votes
1 answer
nuxtserverinit and user login
I'm working on a nuxt app and need to get data from an api. Data only needs to be served to logged in user. In my vuex store index.js, I wrote the following code:
async nuxtServerInit({ commit }) {
if (this.$auth.loggedIn) {
await…

EECode
- 86
- 4
1
vote
1 answer
NUXTJS SSR: I have problems with the nuxtServerInit, the req.headers.cookie of the nuxtServerInit is undefined and the cookie is already in my browser
I am new to NuxtJS and have a problem, I am trying to get the token of the user who logged in from the website, the token is stored in the cookie, but, when I start or reload the website page (made with nuxt ssr (universal )), nuxtServerInit should…

guillepaivag
- 21
- 4
1
vote
0 answers
Why it shows Request failed with status code 401?
I am getting data in Nuxt server init with axios, Request failed with status code 401, and createError
await $axios
.get("/shopping/get-wishlist")
.then(response => {
commit('setWishlist',…

Tolib Rakhmonov
- 83
- 8
0
votes
0 answers
nuxtServerInit is not calling on production server - Nuxt.js
There are many threads about this question. I tried all but nothing seems to work so I am posting this question. I have done the following way.
store/actions.js
const actions = {
async nuxtServerInit ({ commit, dispatch }, ctx) {
…

Dhara
- 1,431
- 4
- 29
- 47
0
votes
1 answer
Nuxt serverInit axios on localhost getting ENOTFOUND
I'm making a website using NuxtJS for the front-end, and Laravel for the backend.
I need to have some data available on every page, so I fetch it using the nuxtServerInit function like so:
async nuxtServerInit({ commit }, { $axios }) {
const…

Maxence Pucheu
- 1
- 2
0
votes
1 answer
nuxtServerInit does not receive auth cookies
I have nuxtServerInit function and it should receive all users' browser data including cookies, but it does not receive the auth module (but not every time!) cookies (I'm talking about JWT Bearer token).
async nuxtServerInit(store, { req }) {
…

Jack Hamer
- 21
- 4
0
votes
0 answers
Dispatch actions on authentication with Nuxt.js
I have an nuxt.js app that a user can log in to. Whenever the user is authenticated using the nuxt/auth module. I want the app to fetch some data using the nuxtServerInit.
Currently I have this in my nuxtServerInit:
export const actions = {
…

Chris Nielsen
- 1
- 1
0
votes
1 answer
Why nuxtServerInit req session Repeated receiving and not receiving data?
My Project is Nuxt.js
Here is My Github > https://github.com/zoz0312/Nuxt_Blog
Question. my nuxt store action, nuxtServerInit req Repeated receiving and not receiving data
Help me
This is scenario
Server Start
Login and make session
refresh…

AJu
- 121
- 1
- 9
0
votes
1 answer
Using Axios within nuxtServerInit()
I need to get remote data to be displayed in every pages.
This call is perfomed in store/index.js:
export const state = () => ({
contact: {
hello: "World"
}
});
export const actions = {
async nuxtServerInit({ commit, state }) {
const…

Yako
- 3,405
- 9
- 41
- 71