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

Add a warning when using encoding in SSR and headers on objects in endpoints #6358

Merged
merged 9 commits into from
Feb 27, 2023

Conversation

Princesseuh
Copy link
Member

Changes

Title is a mouthful. Basically, encoding is only used to write the files when doing static generation, as such in SSR it doesn't do anything, but people expect it to affect the charset, but since #3841 we always default to charset=utf-8. In the future, it would be much better if we only returned responses...

The warning for headers is because returning an object with a certain type of body trips up TypeScript into thinking you're returning a Response since they're "compatible", so a small warning will help nudge users in the right direction.

Close #3841

Testing

N/A. Tested the warning manually

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2023

🦋 Changeset detected

Latest commit: 1946122

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 24, 2023
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick suggestion

packages/astro/src/core/endpoint/index.ts Outdated Show resolved Hide resolved
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should account for prerender as well

packages/astro/src/core/endpoint/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check should apply to both headers and encoding I think?

packages/astro/src/core/endpoint/index.ts Outdated Show resolved Hide resolved
packages/astro/src/core/endpoint/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@natemoo-re natemoo-re merged commit 95164bf into main Feb 27, 2023
@natemoo-re natemoo-re deleted the fix/vercel-images branch February 27, 2023 18:07
@astrobot-houston astrobot-houston mentioned this pull request Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants