0

On localhost I'm running a nodejs, express, and handlebars app. It works fine.

However, when I deploy my app on AWS Elastic Beanstalk everything still works except the server can't find an img that I use.

Here are more details:

In main.handlebars:

<!doctype html>
<html>
<head>
<title>MyApp</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container">
<header>
<img src="/img/myimage.png" class="img-rounded" alt="Myimage logo">
</header>
</div>
{{{body}}}
</body>
</html>

in app.js:

.
.
app.use(express.static(path.join(__dirname, 'public')));

On AWS EB I am not using a proxy server. I tripled-checked that the img was zipped up in the source bundle.

Why is my image not found?

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
  • You say that the server can't find an image - is that because it gives a 404 response to the image request? If you put the complete image URL in a browser, does that show it? – Andrew Morton Oct 27 '17 at 18:06
  • i get a 404 and also the complete image URL doesn't show it in the browser. – juliebulie765 Oct 27 '17 at 18:12
  • [I can't find my Web app when I SSH to my AWS Elastic Beanstalk instance](https://stackoverflow.com/q/27973619/1115360) might help you to check if "myimage.png" is on the server and in the location you intend it to be. – Andrew Morton Oct 27 '17 at 18:23
  • @AndrewMorton comment led to the solution. Image was in the correct directory but the file extension was `PNG`. In the code it was lowercase `png`. My machine didn't complain when I ran it locally. Thank you for your suggestion. – juliebulie765 Oct 27 '17 at 20:31
  • You're welcome :) You could write up your own answer to the question noting that AWS services are case-sensitive. – Andrew Morton Oct 27 '17 at 20:38

0 Answers0