Next.js: Getting 404 Failed to Load Resource [commons.js, mainfest.js, main.js, _error.js]

Created on 20 Mar 2018  Â·  7Comments  Â·  Source: vercel/next.js

Getting multiple 404 errors when loading any page. It's only in Safari.

screen shot 2018-03-19 at 10 25 39 pm

I am using a custom server.

screen shot 2018-03-19 at 10 26 59 pm

Most helpful comment

All 7 comments

It's .map files, you probably don't have production sourcemaps enabled and safari tries to fetch them when you have devtools open. Not much we can do about that.

@timneutkens How do I enable production sourcemaps?

I have a pretty similiar error, but only when I try to run my custom server in Window

const express = require('express');
const next = require('next');

const port = parseInt(process.env.PORT, 10) || 3001;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();

app.prepare()
    .then(() => {
        const server = express();

        server.get('/', (req, res) => {
            res.set({
                'content-type': 'text/html; charset=utf-8'
            });
            return app.render(req, res, '/index', req.query)
        });

        server.get('/about', (req, res) => {
            res.set({
                'content-type': 'text/html; charset=utf-8'
            });
            return app.render(req, res, '/about', req.query)
        });

        server.listen(port, (err) => {
            if (err) throw err;
            console.log(`> Ready on http://localhost:${port}`)
        })
    });
GET http://localhost:3001/_next/-/page/index.js net::ERR_ABORTED
localhost/:1 GET http://localhost:3001/_next/-/page/_error.js net::ERR_ABORTED
(index):1 GET http://localhost:3001/_next/-/manifest.js net::ERR_ABORTED
(index):1 GET http://localhost:3001/_next/-/commons.js net::ERR_ABORTED
(index):1 GET http://localhost:3001/_next/-/main.js net::ERR_ABORTED
(index):14 GET http://localhost:3001/_next/-/page/index.js net::ERR_ABORTED
5
Refused to execute script from '<URL>' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
(index):14 GET http://localhost:3001/_next/-/page/_error.js net::ERR_ABORTED
(index):14 GET http://localhost:3001/_next/-/manifest.js net::ERR_ABORTED
(index):14 GET http://localhost:3001/_next/-/commons.js net::ERR_ABORTED
(index):14 GET http://localhost:3001/_next/-/main.js net::ERR_ABORTED


What is weird here is the dash in between _next/-/page, that looks like Next is not compiling properly.
What could it be the problem?

With the upcoming canary release (1 more pull request till it's out) the files will be loaded just like other static files. And even have a hash in production.

In your case it looks like you forgot to add handle as per the example:
https://github.com/zeit/next.js/blob/canary/examples/custom-server-express/server.js#L25-L27

I'm getting this error in chrome

this happens when I run the server and load the page. The page doesn't load. In order to load the page, I have to hard reset.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rauchg picture rauchg  Â·  3Comments

YarivGilad picture YarivGilad  Â·  3Comments

wagerfield picture wagerfield  Â·  3Comments

ghost picture ghost  Â·  3Comments

formula349 picture formula349  Â·  3Comments