Skip to content
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

Data is not fetched after redirection to the same page (with different parameters) #347

Open
rovitch opened this issue Jan 12, 2025 · 1 comment

Comments

@rovitch
Copy link

rovitch commented Jan 12, 2025

Hi,

I'm trying to redirect to the same page but with different parameters (page type in my case) but the data is not retrieved after the redirection or an error occurred with ssr enabled

Steps to reproduce

  • Follow pwa-demo installation steps
  • Add a redirection in backend module like this :
    • Source Path : /pages
    • Target : t3://page?uid=110&test=1
    • Keep GET Parameters : true

With SSR disabled

Clicking "Pages" link on the menu

  • /pages is fetched and a redirect is emitted
    {
        "redirectUrl":"/pages?test=1\u0026cHash=599baf8f632105a17acf088151dc02d6",
        "statusCode":307
    }
  • the url is modified as expected
  • the data is not retrieved and the old page is still displayed

Accessing /pages on new tab (full app reload)

  • Same as clicking "Pages": /pages is fetched, a redirect is emitted and the url is modified as expected
  • the data is not retrieved and an empty page is displayed

With SSR enabled

Clicking "Pages" link on the menu

  • same behavior as with ssr disabled

Accessing /pages on new tab (full app reload)

  • Initial data is fetched with page parameters, in this case a 404 is returned because the chash is invalid
    Initial Data is unavailable: (404 Not Found (https://pwa-demo.ddev.site/headless/?test=1&cHash=599baf8f632105a17acf088151dc02d6&type=834))
    

Some clues

I tried something like this, it works when clicking the link from the menu with the app fully loaded but there is an infinite loop when accessing by direct link

const getPageData = async (path: string) => {
    const { data, error } = await useAsyncData('t3:page', () => getPage(path))

    if (data.value) {
      if (data?.value?.redirectUrl) {
        await redirect(data.value);
        return getPageData(data.value.redirectUrl);
      }
      pageData.value = data.value
    }
    [...]

Thanks for your help

@rovitch
Copy link
Author

rovitch commented Feb 7, 2025

Hi!

Any news on the issue?
Is this clear enough, or would you like more information about the problem?

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant