I am working on nuxt-edge
+ auth.nuxt
+ vuex
project and in the nuxtServerInit
method of the store I am only logging a message in the console. When the site is reloaded the message gets printed multiple times. This seems to happen only in dev
mode.
Asked
Active
Viewed 1,563 times
6

Slim
- 1,924
- 1
- 11
- 20
-
3Whenever I ran into this problem it was because missing assets would fetch the error page which triggered it's own nuxtServerInit call. – Steve Hynding Sep 18 '18 at 03:13
-
1Seems that the vue devtools extension makes it's own call to the server onload. In Chrome there are multiple (many) requests to the server onload. I had to develop in Firefox because of this issue. – Slim Feb 13 '19 at 08:14
-
@SteveHynding - this comment saved me a LOT of headache. Please add it as an answer! thank you – zerohedge Oct 13 '19 at 20:31
2 Answers
5
Any time an asset is requested from your server that results in an error, Nuxt will render and return an individual error for each file. Error pages are treated like any other page in Nuxt. This means nuxtSeverInit gets called for your initial request and gets called again for each error request on the server.
Check your Network requests to track down each error asset that is requested from your Nuxt server.

Steve Hynding
- 1,799
- 1
- 12
- 22
-
Thank you much! This looks to be my exact scenario. Before I address the root cause I would like to identify these "error requests" so I can skip the app initialization code. How can I identify these requests as "error requests"? Thanks! – user1949561 Feb 05 '21 at 00:43
0
Just discovered that with nuxt all internal links should be created with NuxtLink, not href's, I had a menu bar with hrefs and saw api requests where I did not expect them, as I used NuxtServerInit in the store, but some other links did not result in extra api calls, these links were NuxtLink's.

Gerrit Kuilder
- 11
- 2
-
1Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 07 '21 at 11:56