I use React, React-Router, and Webpack (c webpack-dev-server), and I'm having trouble loading custom fonts on nested routes.
Everything works fine on my small routes, such as /user, /groupetc., but when I have a nested route, for example /group/user, custom fonts do not load (error 404).
In the Webpack assembly, all fonts are placed at the root level (with file names, for example 7f690e503a254e0b8349aec0177e07aa.ttf), and when showing a route, for example /user, fonts are loaded properly.
However, when in a nested route, for example /group/user, the browser tries to download fonts from a URL, for example /group/7f690e503a254e0b8349aec0177e07aa.ttf, which does not exist.
I think that somewhere the font is considered a relative path, but I do not know where.
How can I make font paths absolute paths, not relative? Or is there another way to fix this?
Not sure if this matters, but I defined my fonts as shown below in my file styles.less:
@font-face {
font-family: 'Lato-Regular';
src: url('../fonts/Lato-Regular.ttf') format('truetype');
}