summaryrefslogtreecommitdiff
path: root/packages/integrations/node/src
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2024-08-13 08:58:47 -0400
committerGravatar GitHub <noreply@github.com> 2024-08-13 08:58:47 -0400
commite4422606e75a4403eeca4b77734efe5137800fd8 (patch)
treebfeb9ee01d30c6447c8b0442ba8e37f071a07689 /packages/integrations/node/src
parent26c65914b1b900170e29a8f190e8948a24149338 (diff)
downloadastro-e4422606e75a4403eeca4b77734efe5137800fd8.tar.gz
astro-e4422606e75a4403eeca4b77734efe5137800fd8.tar.zst
astro-e4422606e75a4403eeca4b77734efe5137800fd8.zip
Encrypt server islands props (#11535)
* Encrypt server islands props * Comment on the hex algo * Use @oslojs/encoding * Rename functions * Add base to test * Remove old tests no longer valid * Run test locally * Make sure adapters run before manifest * Add a changeset * Adjust test adapter * don't assume adapter is at root * Add a changeset * Updates on review comments * Update oslo * Add better description of Node adapter change
Diffstat (limited to 'packages/integrations/node/src')
-rw-r--r--packages/integrations/node/src/serve-static.ts9
-rw-r--r--packages/integrations/node/src/server.ts3
2 files changed, 10 insertions, 2 deletions
diff --git a/packages/integrations/node/src/serve-static.ts b/packages/integrations/node/src/serve-static.ts
index 8256c588e..e5cd73daf 100644
--- a/packages/integrations/node/src/serve-static.ts
+++ b/packages/integrations/node/src/serve-static.ts
@@ -103,7 +103,14 @@ function resolveClientDir(options: Options) {
const clientURLRaw = new URL(options.client);
const serverURLRaw = new URL(options.server);
const rel = path.relative(url.fileURLToPath(serverURLRaw), url.fileURLToPath(clientURLRaw));
- const serverEntryURL = new URL(import.meta.url);
+
+ // walk up the parent folders until you find the one that is the root of the server entry folder. This is how we find the client folder relatively.
+ const serverFolder = path.basename(options.server);
+ let serverEntryFolderURL = path.dirname(import.meta.url);
+ while(!serverEntryFolderURL.endsWith(serverFolder)) {
+ serverEntryFolderURL = path.dirname(serverEntryFolderURL);
+ }
+ const serverEntryURL = serverEntryFolderURL + '/entry.mjs';
const clientURL = new URL(appendForwardSlash(rel), serverEntryURL);
const client = url.fileURLToPath(clientURL);
return client;
diff --git a/packages/integrations/node/src/server.ts b/packages/integrations/node/src/server.ts
index e5b503292..1bb27e002 100644
--- a/packages/integrations/node/src/server.ts
+++ b/packages/integrations/node/src/server.ts
@@ -4,6 +4,8 @@ import createMiddleware from './middleware.js';
import { createStandaloneHandler } from './standalone.js';
import startServer from './standalone.js';
import type { Options } from './types.js';
+// This needs to run first because some internals depend on `crypto`
+applyPolyfills();
// Won't throw if the virtual module is not available because it's not supported in
// the users's astro version or if astro:env is not enabled in the project
@@ -11,7 +13,6 @@ await import('astro/env/setup')
.then((mod) => mod.setGetEnv((key) => process.env[key]))
.catch(() => {});
-applyPolyfills();
export function createExports(manifest: SSRManifest, options: Options) {
const app = new NodeApp(manifest);
options.trailingSlash = manifest.trailingSlash;