This is my project folder
/
public/
index.html
main.js
adaptor.js
main.css
node_modules/
socket.io/
index.js
and this is static file configuration in my index.js
app.use(express.static(path.join(__dirname, '/public')));
app.use(express.static(path.join(__dirname, '/node_modules')));
app.get('/', (req, res)=>{
res.sendFile(path.join(__dirname, 'public', '/index.html'));
})
and this is my index.html
<script src="/socket.io/socket.io.js" charset="utf-8"></script>
<script src="/adapter.js" charset="utf-8"></script>
<script src="/main.js" charset="utf-8"></script>
and this is my nginx configuration
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html =404;
proxy_pass http://localhost:8080;
}
But I am getting 404 on all the scripts. And an another strange thing is that mime-type on those files is set to text/HTML
What am I doing wrong here?
I have a project, with an identical project structure, and it has the same configuration, but it works for it, and it isn't working in this case.
See Question&Answers more detail:os