-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed as not planned
Description
Preface
I have been working on a certain Nuxt App for a year. For a long time, the app did not have a /server part so npm run generate
was what I used for building it and it never failed me.
However, I came across a feature that required me to add the /server route to the app. This merits a change to use npm run build
.
The Issue
- While the app builds correctly, when I preview it with
npm run preview
I am not able to properly load the pages. I mean they do open but none of the public assets are loading meaning where images are supposed to be there is just a blank placeholder there. - Upon looking at the network tab, I see no API calls being made at all e.g. when I click login. I have APIs from external servers that were being called fine with
npm run generate
but afternpm run build
, none of them are working. - In the console, I keep getting the error
Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "application/json". Strict MIME type checking is enforced for module scripts per HTML spec.Understand this error CLi9hGpr.js:1
I believe this means that some scripts are not loading properly or at all, which is nuking the functionality of my website. - Also in the console, I get the warning
The resource http://127.0.0.1:3100/_nuxt/builds/meta/d38f3228-0f27-476b-bba7-449ef79750ad.json was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate
asvalue and it is preloaded intentionally.
which I'm sure has something to do with the build process.
My Expectation
- I expect the app to run properly after running
npm run build
in the browser with API calls to both the /server route and external servers working without any issue. - I expect all my assets to be loaded and page navigation to be as flawless as it is in development mode.
My nuxt.config.ts
file
Before running npm run build
, I ensured to set ssr: true
in my Nuxt config file no other build-related config has been changed. I have also double checked that the URL of files in my public assets is correct but I still can't access the files in my browser.
I am using Nuxt3 so if anyone has any recommendation for how I should go about this, i'd really appreciate.