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 context to Node SSR adapter #3934

Closed
wants to merge 7 commits into from

Conversation

laptou
Copy link

@laptou laptou commented Jul 15, 2022

Changes

  • Added a new property Astro.context which can be accessed by components and a new context property on the argument passed into endpoints
  • This context can be set by passing a third parameter context into the handler in the Node.js adapter

Testing

  • Added a unit test which verifies that the Astro.context global works as expected during SSR.

Docs

withastro/docs#1003

@changeset-bot
Copy link

changeset-bot bot commented Jul 15, 2022

🦋 Changeset detected

Latest commit: 09caf6e

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

This PR includes changesets to release 10 packages
Name Type
astro Minor
@astrojs/node Minor
@e2e/astro-component Patch
@e2e/lit-component Patch
@e2e/preact-component Patch
@e2e/react-component Patch
@e2e/solid-component Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch

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) pkg: integration Related to any renderer integration (scope) labels Jul 15, 2022
@laptou laptou changed the title add context parameter to node SSR adapter Add context to Node SSR adapter Jul 15, 2022
@laptou laptou marked this pull request as ready for review July 15, 2022 00:27
@laptou
Copy link
Author

laptou commented Jul 15, 2022

The reason that I made these changes is that I want to integrate Astro SSR into an existing Koa.js server, and that server uses Passport.js for authentication. Astro SSR fits in neatly as a Koa middleware, but without a way to pass information to the Astro components from the server, its usefulness is limited (for example, I need to be able to pass in the authentication information that is provided by Passport, and it is not trivial to recalculate this information inside the Astro components).

@matthewp
Copy link
Contributor

Thanks for submitting this! The RFC is here: withastro/roadmap#230 for anyone reading this.

Going to close this PR for now to keep the repo tidy. If the RFC is approved you can resubmit. Thanks again.

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) pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants