-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix(Astro global): parity with ctx.site
#10325
Conversation
🦋 Changeset detectedLatest commit: 41d58b2 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 |
We're not supposed to modify the user's |
Yes, that's correct. We are currently adding base to it - this PR makes it so that we don't. |
site: 'https://mysite.dev/blog/', | ||
site: 'https://mysite.dev/subsite/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A subpath to the site seems unnatural. It is possible it was not the intention of the orignal PR in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the TODO
s, what's the plan? Will you create tickets for those or will you solve them in this PR?
I don't know enough about how computeCurrentLocale works to tackle it myself. I can open a p1. |
Linear tickets should be fine |
@@ -131,157 +80,3 @@ class Slots { | |||
return outHTML; | |||
} | |||
} | |||
|
|||
export function createResult(args: CreateResultArgs): SSRResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this function moved out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that the code for the Astro global could live alongside that of APIContext and share the implementation details.
// TODO: look into why computeCurrentLocale() needs routeData.route to pass ctx.currentLocale tests, | ||
// and url.pathname to pass Astro.currentLocale tests. | ||
// A single call with `routeData.pathname ?? routeData.route` as the pathname still fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this puzzled me, too. It requires some investigation. We definitely know that url.pathname
doesn't make the cut because during the build, it contains the actual name of the file, e.g. /index.html
//blog/en.html
. However, in dev it contains the correct data.
Object.defineProperty(response, 'headers', { | ||
value: response.headers, | ||
enumerable: true, | ||
writable: false, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: for a better UX, it's better to provide a custom set
that throws an AstroError
, so we can explain to the user why the operation is forbidden,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to merge once #10325 (comment) is addressed
Great, merging after tests. |
Changes
Astro
global alongside that ofAPIContext
.base
out of the picture while generatingmanifest.site
.Testing
astro-global.test.js
andssr-api-route.test.js
Docs