How can I link to static files when I have a baseURL?
I have a bunch of PDFs in the public folder which I need to link to using NuxtLinks. The documentation says to use the external prop (since the routing will otherwise give a 404 instead of the file), but if I use the external prop, baseURL is ignored.
So for example, if my baseURL is /foo/ and my NuxtLink is made like this: <NuxtLink to="test.pdf">test.pdf</NuxtLink> The link will point to the right place, https://host.com/foo/test.pdf, but I will get a 404.
If I change the link to: <NuxtLink external to="test.pdf">test.pdf</NuxtLink> The link now points to https://host.com/test.pdf which is incorrect, that's not where the public folder is.
Is there a way to fix this, other than manually applying app.baseURL from useRuntimeConfig to every link?
Posted May 22, 2025, 8:43 AM UTC