-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I uploaded image to the server, but failed to bring images #1954
Comments
I haven't used this project myself, but it has helped me learn some new angular features (i came from AngularJS), i can probably help.
So if your folder is
Full Guide from Express.js on serving static files, very useful: Happy MEAN'ing |
Thank you guys, I moved this code in the express.js and tried those code with localhost:4040/images/haha.jpg which exsits in images folder. but I was not able to get any image. |
and you restarted app? otherwise one of those tests should have worked. Sorry i'm still learning how Angular 7+ builds/compiles app, i'm from Angular 1 world and that should have worked. If you can't get the express path to work, and get 401, might be something to configure with the |
Because I am using Nodemon, it automatically restarts the server after saving the file. Thank you so much for your help. |
Hi, |
Hello, |
You have to use cors library if frontend and backend have different url. |
I encountered similar problem in my project. When I enter full url of the image in the browser, it would load. But when I try to load in Here is how I solved it:
I found the solution after reading the mdn docs; link - https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin I think the problem might have arisen because I have included Edit: If you don't want to use The following snippet will resolve most of your cors issues and handle preflight requests and It doesn't require any extra library. Modify it as per your requirements.
Something I discovered: For e.g. Lets say I start my web app on
Now when I search |
-mean
-----server
--------- config
-------------config.js
-------- controllers
-------- data
-------- images <---I saved images here using "multer "package
I added this line in mean/server/config/config,js
When I try to access a static image from the browser=>localhost:4040/images
it gives me 401 Unauthorized error.
I don't know why it does not work.
Could you please able to give me an advice?
The text was updated successfully, but these errors were encountered: