yabadabaduhast
yabadabaduhast

Reputation: 109

Astro ssr can not find css files

Followed Astro instructions to build Astro app But the app can not find the assets

Steps to produce:

  1. Create empty astro project from template
  2. Add @astro/node to project npx astro add node
  3. Run npm run build
  4. Serve the server node ./dist/server/entry.mjs as documentation said

It gives this error like below and doesn't apply css.

asset not found error

Upvotes: 0

Views: 1693

Answers (1)

wassfila
wassfila

Reputation: 1911

I recommend you try with the latest version or provide the version you tested with. I tried the same steps as you did, using

npx astro create
npx astro add node

which used version v1.6.15 I did got a build error Setting the 'mode' option is required so I updated the astro.config.js to look as follows :

import { defineConfig } from 'astro/config';

// https://astro.build/config
import node from "@astrojs/node";

// https://astro.build/config
export default defineConfig({
  output: "server",
  adapter: node({
    mode: 'standalone'
  })
});

after that build and run went smooth

npm run build
node ./dist/server/entry.mjs

as you can see css correctly loaded enter image description here

Upvotes: 2

Related Questions