M_eight
M_eight

Reputation: 201

Getting 404 errors when trying to use Fontawesome fonts locally in express.js framework

When I try to use fontawesome locally I am always getting 404 error when the browser tries to load the fonts. I'm pretty sure I have set the path correctly.

I have set the static paths in app.js as follows.

app.use(express.static(__dirname + '/Content'));
app.use(express.static(__dirname + '/webfonts'));

404 errors

Upvotes: 0

Views: 387

Answers (1)

JBaczuk
JBaczuk

Reputation: 14589

You are referencing webfonts at the /webfonts endpoint, but when you do not provide a path as the first parameter, it will be hosted at root. So, either reference the webfonts without the /webfonts prefix, or try giving them an endpoint as the first parameter:

app.use('/Content', express.static(__dirname + '/Content'));
app.use('/webfonts', express.static(__dirname + '/webfonts'));

See Express Docs - app.use

Upvotes: 1

Related Questions