Good afternoon, I did an API with Node and consumed it with React, in development environment, it works OK because I started one independent of the other, but in production I'm trying to deliver the static files compiled by React to the Node. 3 files. An HTML, CSS and JS. HTML is being delivered perfectly, however, JS and CSS do not seem to be OKs.
In this case, the HTML is being delivered because the title and icon are working, but the screen is white and the console displays the following message: " Failed to load with font" link
In the case, I am delivering the public folder of the second form:
if (process.env.PRODUCTION) {
app.set('public', path.resolve(__dirname, '../../public'));
app.use(express.static(app.get('public')));
}
When the "/" route is accessed, it will play the other files together.
server.get('/', (req, res) => {
if (process.env.PRODUCTION) {
res.sendFile(path.resolve(__dirname, '../../../public/index.html'));
} else {
res.status(500).send({
message: 'API rodando em ambiente de desenvolvimento!'
})
}
});
I tried to play the static JS and CSS files together in "res.sendFile", but it did not work, the message continued. Could anyone tell me what it might be?
Thank you!