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

Support @astrojs/[email protected] and above #1340

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hip-trees-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystatic/astro': patch
---

Support `@astrojs/[email protected]` and above
50 changes: 27 additions & 23 deletions packages/astro/src/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,34 @@ import type { APIContext } from 'astro';
import { parseString } from 'set-cookie-parser';

export function makeHandler(_config: APIRouteConfig) {
const handler = makeGenericAPIRouteHandler(
{
..._config,
clientId:
_config.clientId ??
tryOrUndefined(() => {
return import.meta.env.KEYSTATIC_GITHUB_CLIENT_ID;
}),
clientSecret:
_config.clientSecret ??
tryOrUndefined(() => {
return import.meta.env.KEYSTATIC_GITHUB_CLIENT_SECRET;
}),
secret:
_config.secret ??
tryOrUndefined(() => {
return import.meta.env.KEYSTATIC_SECRET;
}),
},
{
slugEnvName: 'PUBLIC_KEYSTATIC_GITHUB_APP_SLUG',
}
);
return async function keystaticAPIRoute(context: APIContext) {
const envVarsForCf = (context.locals as any)?.runtime?.env;
const handler = makeGenericAPIRouteHandler(
{
..._config,
clientId:
_config.clientId ??
envVarsForCf?.KEYSTATIC_GITHUB_CLIENT_ID ??
tryOrUndefined(() => {
return import.meta.env.KEYSTATIC_GITHUB_CLIENT_ID;
}),
clientSecret:
_config.clientSecret ??
envVarsForCf?.KEYSTATIC_GITHUB_CLIENT_SECRET ??
tryOrUndefined(() => {
return import.meta.env.KEYSTATIC_GITHUB_CLIENT_SECRET;
}),
secret:
_config.secret ??
envVarsForCf?.KEYSTATIC_SECRET ??
tryOrUndefined(() => {
return import.meta.env.KEYSTATIC_SECRET;
}),
},
{
slugEnvName: 'PUBLIC_KEYSTATIC_GITHUB_APP_SLUG',
}
);
const { body, headers, status } = await handler(context.request);
// all this stuff should be able to go away when astro is using a version of undici with getSetCookie
let headersInADifferentStructure = new Map<string, string[]>();
Expand Down
Loading