In Astro, fetch calls with relative routes may produce an error message. If you write the fetch call without any useEffect
hooks, then it will also execute for the initial server side render. Fetch on the server needs the fully qualified route, because fetch on the server doesn’t know its own base route (e.g. www.mydomain.com). If you wrap fetch in a hook, you are forcing the fetch call only to happen on the client side and you can use a relative route.
Fetch Calls in Astro With Relative Routes
Posted on:October 21, 2024