Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

next.js deployed using now missing styles, styles.css 404 response

I'm building a simple site for a school project using next, and I managed to deploy the next.js app using now, but no styles are being applied. Everything is fine and works (looks) great on localhost but not online (https://spa-ot24z7ugt.now.sh).

I guess it has something to do with the now.json file, but their documentation makes it look like everything will just work out of the box, and it kind of is true, except for the styling. I looked at the documentation and could not find anything and I was wondering if anyone has any experience using now and next.js.

my now.json file:

```{
  "version": 2,
  "builds": [
    { "src": "next.config.js", "use": "@now/next" }
  ]
}```

link to the deployed site: https://spa-ot24z7ugt.now.sh

I'm using Head from 'next/head' to generate link a static CSS file.

like image 375
Aiden Campbell Avatar asked Oct 27 '25 06:10

Aiden Campbell


1 Answers

I had the same issue and the fix for me was to include style.css as static build:

{
    "version": 2,
    "name": "wp-nextjs",
    "public": true,
    "builds": [
        { "src": "package.json", "use": "@now/next" },
        { "src": "static/css/style.css", "use": "@now/static" }
    ]
}
like image 115
Goran Jakovljevic Avatar answered Oct 28 '25 20:10

Goran Jakovljevic