[SOLVED] Correct Asset Paths for Server Side Rendering vs Static File Serving


My app directory structure is something like this:

    main.rs -- where my server runs
    templates.rs -- where the server side rendering templates are called from, including template that calls /elm.js (this path works b/c I am serving the elm/ directory itself as well)
         index.html -- static file that calls elm.js
            Main.elm -- path to image assets is "src/Icons/<specific image file>"
            images/ -- all my icons and other image assets

When I serve the static index.html file the image assets are loaded appropriately. However, when I load elm.js from one of my server side rendered templates, the image assets are not found. I have tried moving the assets folder to root/src/images thinking that would be the equivalent relative path to main.rs as the current path is to index.html, but that does not seem to work. Where should these assets be for the javascript file to find them when it is called from a server side template?


N/M. I had the route for the server side rendered template a level lower than the static file route. By putting the routes at the same level the image assets are served appropriately.

closed #2

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.