Skip to content

Commit

Permalink
allow server islands to omit encrypted props when they do not have an…
Browse files Browse the repository at this point in the history
…y props
  • Loading branch information
kaytwo committed Jan 10, 2025
1 parent 4141359 commit a5f2fee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/core/server-islands/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function createEndpoint(manifest: SSRManifest) {
const key = await manifest.key;
const encryptedProps = data.encryptedProps;

const propString = await decryptString(key, encryptedProps);
const propString = encryptedProps === '' ? '{}' : await decryptString(key, encryptedProps);
const props = JSON.parse(propString);

const componentModule = await imp();
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/src/runtime/server/render/server-islands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export function renderServerIsland(
}

const key = await result.key;
const propsEncrypted = await encryptString(key, JSON.stringify(props));
const propsEncrypted =
Object.keys(props).length === 0 ? '' : await encryptString(key, JSON.stringify(props));

const hostId = crypto.randomUUID();

Expand Down

0 comments on commit a5f2fee

Please sign in to comment.