app.use(express.static('/static'));
means that the static files are served literally from /static
. In a Unix-Based Operating System, this is a direct child to the directory root /
. I don't think you do, but you shouldn't store files, let alone publicly accessible files in that directory. Instead what you are probably looking for is the static
directory in your App's directory.
This is how you can tell express to use that one to server files:
app.use(express.static(__dirname + "/static"));
The MIME Type Error is happening because the file served is likely a "404 Not Found" page made by Express, because it couldn't locate the CSS file. The browser expects a CSS file, gets an HTML file and says the MIME Type doesn't fit.
If you can't include a file in your HTML always double, or better even tripple check, that the file can be accessed through the browser first.
Also, the files are then located in ... href="/..."
, not ... href="/static/..."
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…