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

node standalone server does not serve assets (unless you run astro preview) #5093

Closed
1 task done
bholmesdev opened this issue Oct 14, 2022 · 2 comments · Fixed by #5114
Closed
1 task done

node standalone server does not serve assets (unless you run astro preview) #5093

bholmesdev opened this issue Oct 14, 2022 · 2 comments · Fixed by #5114
Assignees
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)

Comments

@bholmesdev
Copy link
Contributor

What version of astro are you using?

1.5.0

Are you using an SSR adapter? If so, which one?

@astrojs/node

What package manager are you using?

pnpm

What operating system are you using?

Mac

Describe the Bug

The docs say you can run the node server directly when using standalone mode like so:

node ./dist/server/entry.mjs

However, doing so will only start the base server without serving any static assets.
image

Interestingly, astro preview will start this same server with static asset serving, though this nuance isn't documented. Curious if this is a bug or just a documentation issue?

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-hvcn2g

Participation

  • I am willing to submit a pull request for this issue.
@ColinFrick
Copy link

resolvePaths in standalone.ts seems to return the wrong path to the client:

function resolvePaths(options: Options) {
const clientURLRaw = new URL(options.client);
const serverURLRaw = new URL(options.server);
const rel = path.relative(fileURLToPath(serverURLRaw), fileURLToPath(clientURLRaw));
const serverEntryURL = new URL(import.meta.url);
const clientURL = new URL(appendForwardSlash(rel), serverEntryURL);
return {
client: clientURL,
};
}

This returns an url relative to standalone.ts / standalone.js: file:///[...]/website/node_modules/@astrojs/node/client/ instead of file:///[...]/website/dist/client/

@matthewp matthewp added the - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) label Oct 18, 2022
@matthewp
Copy link
Contributor

Hm, this works for the examples/ssr example, i'll investigate what's up with your stackblitz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants