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

Astro redirects should not generate HTML stubs when using an adapter #7731

Closed
1 task
mashehu opened this issue Jul 20, 2023 · 9 comments · Fixed by #7805
Closed
1 task

Astro redirects should not generate HTML stubs when using an adapter #7731

mashehu opened this issue Jul 20, 2023 · 9 comments · Fixed by #7805
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: ssr Related to SSR (scope) pkg: node Related to Node adapter (scope) pkg: vercel Related to Vercel adapter (scope)

Comments

@mashehu
Copy link

mashehu commented Jul 20, 2023

What version of astro are you using?

2.8.5

Are you using an SSR adapter? If so, which one?

Netlify

What package manager are you using?

npm

What operating system are you using?

MacOS

What browser are you using?

Chrome, Firefox

Describe the Bug

When using configured redirects on netlify I see the placeholder HTML with "Redirecting to: " for a moment, before the browser is redirected to the correct site.

What's the expected result?

Based on the wording in the documentation:

When running astro build, Astro will output HTML files with the meta refresh tag by default. Supported adapters will instead write out the host’s configuration file with the redirects.

I assumed that the netlify adapter, would only write to the _redirects file, without generating these placeholder files, which give a quick flash of an unstyled page between pages.

See my minimal example deployment: https://main--thriving-dusk-04bc5b.netlify.app/

Link to Minimal Reproducible Example

https://github.com/mashehu/astro-quickstart/tree/main

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jul 20, 2023
@jdozierezell
Copy link

I just dropped by to create the same issue. This began appearing after a recent update of the adapter and was not present prior to that.

@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Jul 20, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jul 20, 2023
@natemoo-re
Copy link
Member

Ah yep, this behavior became more noticable when #7644 was merged, but I suspect this has never worked properly in hybrid mode.

We should be bypassing these files in hybrid mode as well and only generate the _redirects file so Netlify can handle it.

@Princesseuh Princesseuh added the feat: ssr Related to SSR (scope) label Jul 20, 2023
@natemoo-re natemoo-re changed the title configured redirects on netlify: placeholder file should be removed Astro redirects should not generate HTML stubs when using an adapter Jul 24, 2023
@natemoo-re natemoo-re added the pkg: vercel Related to Vercel adapter (scope) label Jul 24, 2023
@natemoo-re
Copy link
Member

natemoo-re commented Jul 24, 2023

This is also relevant for the Vercel and Node adapters in hybrid mode

@natemoo-re natemoo-re added the pkg: node Related to Node adapter (scope) label Jul 24, 2023
@fprl
Copy link
Contributor

fprl commented Jul 25, 2023

Before creating a new issue:

I am trying to implement redirects but its not working in prod (in dev all good):

redirects: {
  '/my-account/my-bookings/[hash]': '/nl/my-account/bookings/[hash]',
  '/my-account/my-profile': '/nl/my-account/profile',
  '/en/my-account/my-bookings/[hash]': '/my-account/bookings/[hash]',
  '/en/my-account/my-profile': '/my-account/profile',
  },

Everything gets redirected to /. Maybe this feature is for static builds? I'm using node adapter (I also see the placeholder).

Is this related to this issue? Thanks

@matthewp
Copy link
Contributor

You can disable the stubs with build.redirects = false while still getting the _redirects config update. I think I agree that Netlify should be setting this for you. I'll look into it.

@jdozierezell
Copy link

@matthewp it looks like skipping the stubs now results in redirects being case sensitive (as is typical with redirects set directly in Netlify). Is there a workaround for this or a way to reactivate the stubs via config setting? Skipping stubs is great, but now I'm dealing with a bunch of broken links.

@paulrudy
Copy link
Contributor

This is also relevant for the Vercel and Node adapters in hybrid mode

I'm still seeing the "Redirecting to..." placeholders in Vercel. astro v 2.9.6, @astrojs/vercel v 3.7.4.

@disrae
Copy link

disrae commented Jan 5, 2024

You can disable the stubs with build.redirects = false while still getting the _redirects config update. I think I agree that Netlify should be setting this for you. I'll look into it.

When I set build.redirects = false, the redirects stop working. Vercel and SSG.

@zellwk
Copy link

zellwk commented Jul 5, 2024

This seems to happen on the latest Astro version. I'm using a Node adaptor and I still see the stub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: ssr Related to SSR (scope) pkg: node Related to Node adapter (scope) pkg: vercel Related to Vercel adapter (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants