Giter Site home page Giter Site logo

Comments (7)

danielroe avatar danielroe commented on August 15, 2024 1

@AdrianFahrbach You can also set experimental.payloadExtraction to true to ensure useAsyncData only runs on the server for all routes.

from nuxt.js.

danielroe avatar danielroe commented on August 15, 2024

You can pass the external prop to force a hard reload, though note this will probably lead to a worse UX.

from nuxt.js.

sznski avatar sznski commented on August 15, 2024

You can pass the external prop to force a hard reload, though note this will probably lead to a worse UX.

then there's no correct way to prevent page do client requests when they should be server side?

from nuxt.js.

sznski avatar sznski commented on August 15, 2024

i think it sounds insecure. like, what if i pass secret api key which only server should use? creating nuxt api layer to proxy sounds not that good if not every route requires this type of key.

from nuxt.js.

sznski avatar sznski commented on August 15, 2024

You can pass the external prop to force a hard reload, though note this will probably lead to a worse UX.

and it doesn't work !)

const handlePayment = async () => {
	// TODO: handle payment
	return navigateTo('/delivery/' + offerId, {
		external: true,
	});
};

still client requests on the navigated page, and even when i move in history like clicking back and forward buttons in browser i see client requests. would be cool to see some info on nuxt docs about this type of simple tasks, how to make it correct way how nuxt devs would do it.

from nuxt.js.

danielroe avatar danielroe commented on August 15, 2024

Please provide a reproduction if it doesn't work.

I would recommend you consider server components or create a BFF using Nitro server routes.

from nuxt.js.

AdrianFahrbach avatar AdrianFahrbach commented on August 15, 2024

So the only ways to solve this are:

  1. External links everywhere (basically not using NuxtLink)
  2. Wrapping server side api requests into a server component
  3. BFF Nitro server routes

@danielroe Do you have improvements for this planned in the future? I would definitely prefer an option to force useAsyncData to only run on the server.

Could you also elaborate on the BFF Nitro server route approach a bit? My guess is that the solution there would be to create an internal API route that caches the data fetched from external sources, but still gets called on the client.

from nuxt.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.