aantron/dream

Not able to load images in html

Closed this issue · 6 comments

Hello, it is my first time using dream and I encounter a bug that I can't fix. My image won't load on the HTML page however I can access them directly with their address. Any idea why images are not loading?

Expected result :
image

The result of dream :
The page never finishes loading and the images do not appear.
image

My main code :
image

Logs :
image

@aantron I'll take a look this week. Assign to me please

@aantron I'll take a look this week. Assign to me please

Thank you!

let () =
  Dream.run
  @@ Dream.logger
  @@ Dream.router [
    Dream.get "/" (Dream.from_filesystem "." "/static/index.html");
    Dream.get "/static/**" (Dream.static "./static")
  ]

Using the f-static example, I created a static directory with assets. My /static/index.html loads my image fine.

29.04.23 23:55:28.500       dream.log  INFO REQ 3 GET / ::1:51619 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0
29.04.23 23:55:28.500       dream.log  INFO REQ 3 200 in 542 μs
29.04.23 23:55:28.547       dream.log  INFO REQ 4 GET /static/test.jpg ::1:51619 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Fire0
29.04.23 23:55:28.547       dream.log  INFO REQ 4 200 in 374 μs

The example you're using @OscarLahaie is the w-one-binary example though.

Possible issues

  1. your html page is referencing the images incorrectly
  2. crunch is failing to load properly.

I'll check out the w-one-binary example and see if it works.

w-one-binary works fine too. I built the binary. Copied the binary out to some other area. Ran it, and it served my image.

Can't reproduce.

Thank you for taking a look. I don't remember my exact mistake but it seems I was wrong. So far I have used the following system without crunch
image

Thank you again