next.js icon indicating copy to clipboard operation
next.js copied to clipboard

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

Open brennanerbz opened this issue 8 years ago • 7 comments

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

brennanerbz avatar Mar 20 '18 05:03 brennanerbz

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 avatar Mar 20 '18 08:03 timneutkens

@timneutkens How do I enable production sourcemaps?

brennanerbz avatar Mar 20 '18 16:03 brennanerbz

https://github.com/zeit/next-plugins/tree/master/packages/next-source-maps

timneutkens avatar Mar 20 '18 18:03 timneutkens

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?

maufarinelli avatar Apr 15 '18 15:04 maufarinelli

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

timneutkens avatar Apr 15 '18 21:04 timneutkens

I'm getting this error in chrome

jp26jp avatar Nov 04 '18 05:11 jp26jp

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.

ercekal avatar Apr 12 '19 07:04 ercekal