Closed almiho closed 8 years ago
FlowRouter handles these. You should try accessing your image in your browser like so: http://localhost:3000/img/myBackgroundImage.png
.
Be aware that your files (myBackgroundImage.png
) should be in lowercase to comply with RFC 3986.
OMG, now this is embarrassing! Further to your note I tried to open the image in the browser and it worked. In fact it worked both in the "original" browser and in the Karma window which I use for unit testing. That make me think the bug must actually be sitting in front of the screen, not inside the code.
... and well, what shall I say, I found the issue. One of my test cases has gone wild and the hook for failed image loading was executed explicitly by my own code. Hence, I kept on seeing the error message suggesting that the loading failed - which it didn't.
I am closing this issue as I don't want to waste anybody else's time with it.
Thanks!!! Alex
Hi all,
I am putting together my first app with Meteor, Flow-Router and React and so far things are going pretty well. Now I have run into an issue that I was not able to resolve even after searching the web, reading all guidelines that might seem relevant etc.
My issue: I can't serve static files from the server.
I know Flow-Router is a client side router. That's fine. It works great for me when I want to switch from one client side layout to another. However, in one of my layouts I want to load an image and put it inside an
<img>
on my page.Like so: inside a render function of one of my react components you would find this:
<img src={this.props.backgroundImage} />
an example fixture for this is
{backgroundImage: "/img/myBackgroundImage.png"}
the image is located at
mymeteorfolder/public/img/myBackgroundImage.png
I need to somehow let Flow-Router know to ignore certain URLs, i.e. /img/* so that the content is loaded from the server. I can't imagine I am the first one to run into this. How did you guys solve this problem?
I probably also have to make the img files accessible on the server side in Meteor. Any idea how to do that?
Thank you very much! Alex