Alireza
Difference between server plugin and server route middleware
Hi @kapa.ai
I want to run a function that get's the location of the user form the request (provided by cloudflare). I am using const event = useRequestEvent() which would return value on server requests and undefined on browser navigation.
It works in
/middleware/location.global.ts
I can get the context.cf out of useRequestEvent() and update pinia store value and use that on subsequent client side navigations. It get's updated after reload or other server requests.
It also works when you put the function to run in /plugins/location.server.ts
. My understanding is that the server plugins will run on server requests? Is there a difference between deploying Nuxt on a long running node vs Cloudflare Worker in that sense?
What is the difference between the 2 approaches?20 replies
SSR friendly usePreviousRoute()?
Say a visitor goes to a blog category page at
/cat/tutorials
and then clicks on a blog post going to /article/hello
. The can also reach to /article/hello
from other categories like /cat/videos
. Now I want to create breadcrumbs that would show Posts > Tutorials > Hello
or Posts > Videos > Hello
providing the use navigation path. There will also be a default one if a user directly accesses the article page. How would you go about that?
I was thinking maybe it is possible to access the from
of the routeMiddleware?
24 replies
Example of updating app.config at runtime
Doc says app.config is reactive and can be changed at runtime. The docs does not provide any examples though. https://nuxt.com/docs/guide/directory-structure/app-config
I am looking for an example of how to do that and what are the use cases of this feature. For example, if we have a color: "#fff" in the app.config, can it be changed at the runtime after fetching the value from the database after the user login? like color.value = userColor
It would be also nice if anyone could point to a GitHub repo that uses this or even how to search GitHub to find such a use case.
2 replies