I have the following node server:
var express = require('express');
var app = express();
var path = require('path');
app.set('port', (process.env.PORT || 5000));
app.use(express.static(path.join(__dirname + '/public')));
// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.get('/', function(request, response) {
response.render('pages/index');
});
app.get('/abstract', function(request, response) {
response.render('pages/abstract');
});
app.get('/PCA', function(request, response) {
response.render('pages/PCA');
});
...
Below are my files where app.js is:
- views
- pages
- index.ejs
- abstract.ejs, etc.
- partials
- header.ejs
- nav.ejs
- pages
- public
- css
- main.css
- img
- logo.png
- linear.png
- css
After pushing to heroku, images on the "/" route are rendered. However, on '/abstract' '/PCA', only the images in the nav.ejs are showing up and all other images are not found. My css static file is found on all files. I've tried without success:
<img src="linear.png" id="linear"/>
<img src="img/linear.png" id="linear"/>
<img src="/img/linear.png" id="linear"/>
Thanks for you help!