Reputation: 11137
I have a web server setted up in node.
var app = express();
app.use(express.static(PUBLIC_PATH));
server = require('http').createServer(app),
io = require('socket.io').listen(server);
i set the public path to my app's root public folder, where i keep my frontend, so when the server is deployed, it's /app/public
When i try to open a page, i see this in chrome's console
i Failed to load resource: the server responded with a status of 404 (Not Found)
The file in question is app.js which is located in my public folder. I do see requests from the web server for that certain file
2015-04-04T15:43:04.208178+00:00 heroku[router]: at=info method=GET path="/style.css" host=hive-badescuga.herokuapp.com request_id=2be0334e-e968-4397-8c2e-9c65c85fea22 fwd="188.25.247.211" dyno=web.1 connect=1ms service=6ms status=304 bytes=236
2015-04-04T15:43:04.203415+00:00 heroku[router]: at=info method=GET path="/app.js" host=hive-badescuga.herokuapp.com request_id=fc8c529c-7641-4df2-9b13-5fee9e1af365 fwd="188.25.247.211" dyno=web.1 connect=1ms service=7ms status=404 bytes=217
2015-04-04T15:43:09.152566+00:00 heroku[router]: at=info method=GET path="/style.css" host=hive-badescuga.herokuapp.com request_id=b89ded8e-5433-4b57-8c80-c2e7407d31b0 fwd="188.25.247.211" dyno=web.1 connect=1ms service=6ms status=304 bytes=236
What is the problem?
UPDATE
As i'm debugging further i see that a css in the same root as my app.js (that can't be loaded), gets loaded. Here is my html:
<link rel="stylesheet" href="/style.css">
<script type='text/javascript' src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>
<script src="/app.js"></script>
so style.css does get loaded while app.js doesn't (because it can't be found), and they are in the same folder.
Upvotes: 0
Views: 4522
Reputation: 21
I don't know if it will help, but may be you should write: process.env.PUBLIC_PATH. Also, I don't know if you have this:
var express = require('express');
I have this:
app.use(express.static(path.join(__dirname ,'views')));
Upvotes: 1
Reputation: 11137
All is fixed, had the app.js git ignored so it worked locally but it wasn't uploaded.
Upvotes: 1