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

fix(Astro global): parity with ctx.site #10325

Merged
merged 9 commits into from
Mar 7, 2024
Merged

Conversation

lilnasy
Copy link
Contributor

@lilnasy lilnasy commented Mar 4, 2024

Changes

Testing

  • Added to astro-global.test.js and ssr-api-route.test.js

Docs

  • Does not affect usage.

Copy link

changeset-bot bot commented Mar 4, 2024

🦋 Changeset detected

Latest 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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Mar 4, 2024
@lilnasy lilnasy marked this pull request as ready for review March 4, 2024 20:45
@matthewp
Copy link
Contributor

matthewp commented Mar 4, 2024

We're not supposed to modify the user's site config in any way. We don't add the base or do any other modifications. It's intended to be exactly what's in the user's config, only validated to be a URL. It looks like that's what you're doing here, I just want to confirm that's your expectation as well.

@lilnasy
Copy link
Contributor Author

lilnasy commented Mar 4, 2024

Yes, that's correct. We are currently adding base to it - this PR makes it so that we don't.

Comment on lines -12 to +13
site: 'https://mysite.dev/blog/',
site: 'https://mysite.dev/subsite/',
Copy link
Contributor Author

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.

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.

Regarding the TODOs, what's the plan? Will you create tickets for those or will you solve them in this PR?

packages/astro/src/core/endpoint/index.ts Outdated Show resolved Hide resolved
@lilnasy
Copy link
Contributor Author

lilnasy commented Mar 4, 2024

I don't know enough about how computeCurrentLocale works to tackle it myself. I can open a p1.

@ematipico
Copy link
Member

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

packages/astro/src/core/base-pipeline.ts Show resolved Hide resolved
packages/astro/src/core/endpoint/index.ts Outdated Show resolved Hide resolved
Comment on lines +318 to +320
// 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.
Copy link
Member

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.

Comment on lines 195 to 199
Object.defineProperty(response, 'headers', {
value: response.headers,
enumerable: true,
writable: false,
});
Copy link
Member

@ematipico ematipico Mar 5, 2024

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,

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.

Happy to merge once #10325 (comment) is addressed

@lilnasy
Copy link
Contributor Author

lilnasy commented Mar 7, 2024

Great, merging after tests.

@ematipico ematipico merged commit f33cce8 into withastro:main Mar 7, 2024
14 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Mar 7, 2024
@lilnasy lilnasy deleted the fix/10303 branch March 7, 2024 16:36
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) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

context.site different from Astro.site (missing base / pathname)
4 participants