0

I am trying to store an image to mongodb in react. I am using multer to do the task. But image is not uploading because of the following error:

POST http://localhost:5000/uploadImage 500 (Internal Server Error)

Refused to load the image 'http://localhost:5000/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

My localhost is running at 5000 port from where mongodb is connected as usual. And I am trying to send image from "http://localhost:3000"(react) through this way:

<form
      action="http://localhost:5000/uploadImage"
      method="POST"
      className="mt-5"
    >
      <label htmlFor="input">Banner</label>
      <input type="file" encType="multipart/form-data" name="myImage" />
      <input type="submit" value="upload Image" />
    </form>

How to fix that problem??

Fuad9
  • 353
  • 1
  • 3
  • 19

1 Answers1

0

Please open index.html and find below tags:

<meta http-equiv="Content-Security-Policy" >

and replace with proper content by below instruction.

Content Security Policy: "img-src 'self' data:"