Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource interpreted as Stylesheet but transferred with MIME type text/htm #54

Open
tandat2209 opened this issue Jul 6, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@tandat2209
Copy link

commented Jul 6, 2016

When I put a link css to index.tpl.html
I got this error Resource interpreted as Stylesheet but transferred with MIME type text/html: "..."

And I'm unable to use css.

@akerr95

This comment has been minimized.

Copy link

commented Aug 20, 2016

same problem here. it doesnt happen when i run in production mode but, then i cant hot reload

@lenin-indigo

This comment has been minimized.

Copy link

commented Oct 10, 2016

Hi, i added the next code to the file server.js

app.get('*', function response(req, res) {
        var extension = path.extname(req.url);
        var name = req.url.split('/').pop();
        switch (extension) {
            case '.css':
                res.setHeader("Content-Type", 'text/css');
                res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
                res.end();
                break;
            case '.png':
                res.setHeader("Content-Type", 'image/png');
                res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
                res.end();
                break;
            case '.jpg':
                res.setHeader("Content-Type", 'image/jpeg');
                res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
                res.end();
                break;
            default:
                res.setHeader("Content-Type", 'text/html');
                if (name == 'index.html') {
                    res.write(middleware.fileSystem.readFileSync(path.join(__dirname, 'dist/index.html')));
                    res.end();
                } else {
                    fs.exists(path.join(__dirname, 'dist' + req.url), function (exists) {
                        console.log(exists);
                        if (exists) {
                            res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
                            res.end();
                        }
                    });
                }
                break;
        }
    });
@RandallFlagg

This comment has been minimized.

Copy link

commented Apr 25, 2018

I don't know if it is related to this issue directly, but I had the same issue and it came out to be that I was reported by the devtools that the file was downloaded(code 200) but the actual content inside wasn't the file I expected(css) rather an error message(html).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.