New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
payloadExtraction does not work for alternate URL (with/without trailing slash) when using catchall #19478
Comments
I can reproduce this. It seems that trailing slash URLs do not fetch the payload correctly and fall back to executing the API calls. |
oops 😆 |
It seems that the auto key from This happens because because the path is watched as const { data, pending, error } = await useFetch(url, {
params: {
path: fullPath.replace(/\/$/, ''),
acf_format: 'standard',
_fields: 'acf,title',
},
}); resolves that. |
Thanks for investigating the issue and providing a workaround. I will definitely apply to my project. I think the issue boils down to the following:
|
It is not. When you access e.g.
I just wanted to add that this is the case (hence the different keys), but only one represantation will be actually saved. So for prerendering, trailing and non-trailing versions are treated the same (and they should be the same), but when using the It would be great to provide a DX improvement here so people don't have to take trailing slashes into account. This is related to #15462 where we decided not to apply redirects or similar. Would love to have some feedback from @danielroe on this topic 😋 |
You're absolutely right. I think I get it now. I confused myself thinking the data in the pre tag is an indicator that the payload is loaded instantly. but it's just an html generated from the /careers/ (or /careers) payload which is never matched later when visiting the page. |
Yes, this is a tricky one. I think where people are manually providing their own key then there is little we can do to handle a trailing slash in the URL. (I don't think we want to manipulate the route object to remove the trailing slash, for example.) Other ideas would be very welcome though. |
I agree, this seems too risky in terms of side effects to me too. |
Closing here for now as any ideas on how to interfere/rectify would be more disruptive than helpful. If you are reading this and have an idea - comment please! |
Environment
Linux
v16.14.2
3.2.3
2.2.3
npm@7.17.0
vite
-
-
-
Reproduction
Run the following:
https://stackblitz.com/edit/github-d1s7rg?file=pages/[...slug].vue
Describe the bug
Journey 1: navigating "No Trailing Slash links"
navigation is snappy. no api calls on initial visits or internal routing.
No issues here.
Journey 2: navigating from "No Trailing Slash links" to "Trailing Slash links" internally
Request is executed. page waits for the payload to be fetched from the api. this seems to only happen with dynamic pages.
Browsing a static page will not cause a fetch request. check /test and /test/
-- I noticed that in the fetch, the
pending
flag ofuseFetch
is never true even though the request is fetching in the background.Going back and forth to trailing slash dynamic pages will fetch the page request each time. but note that this is not consistent.
-- Reproduce by: index page => trailing /blog/ => trailing /support/ => trailing /blog/
-- But sometimes it doesn't do that for some reason: try index page => trailing /blog/ => trailing /support/ => trailing /careers/. requests are only executed on initial visits. going back to any page after this journey will load instantly.
Journey 3: Initially visiting Trailing Slash link
I have another reproduction here
details and reproduction steps: Discord thread
@manniL tagged based on your request
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: