prevent warning: Astro.request.headers is not available in "static" output mode#10196
Merged
lilnasy merged 4 commits intowithastro:mainfrom Feb 24, 2024
Merged
prevent warning: Astro.request.headers is not available in "static" output mode#10196lilnasy merged 4 commits intowithastro:mainfrom
Astro.request.headers is not available in "static" output mode#10196lilnasy merged 4 commits intowithastro:mainfrom
Conversation
🦋 Changeset detectedLatest commit: a39335b 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 |
Princesseuh
approved these changes
Feb 22, 2024
Member
Princesseuh
left a comment
There was a problem hiding this comment.
Not 100% familiar with the code here, but this looks fine to me!
matthewp
reviewed
Feb 22, 2024
92f43bf to
9506eb6
Compare
1 task
Contributor
|
Closes #10212 |
matthewp
approved these changes
Feb 23, 2024
ematipico
requested changes
Feb 23, 2024
| // TODO: we are making two calls to computeCurrentLocale(). In various cases, one works and the other doesn't. | ||
| // Ideally, we could use `renderContext.pathname` which is intended to be the one true "file-system-matchable" path. | ||
| // - Arsh | ||
| return this.#currentLocale ??= computeCurrentLocale(url.pathname, locales, strategy, defaultLocale) ?? computeCurrentLocale(routeData.route, locales, strategy, defaultLocale); |
Member
There was a problem hiding this comment.
As mentioned in the previously, we can't use url.pathname because in SSG we get a URL like /en.html, and we won't be able to provide the current locale.
We need to use routeData.pathname if it exists, and routeData.route as a fallback. Also. this code be cleaned up:
return this.#currentLocale = computeCurrentLocale(url.pathname ?? routeData.route, locales, strategy, defaultLocale)
lilnasy
commented
Feb 23, 2024
lilnasy
commented
Feb 23, 2024
ematipico
reviewed
Feb 23, 2024
ematipico
approved these changes
Feb 24, 2024
Merged
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
preferredLanguage, for example, involves reading theAccept-Languageheader.Testing
Existing tests should pass.
Docs
Does not affect usage.