Barryvdh /laravel-cors: public/img

Nginx configuration

      location ~ /img {

          add_header Content-Type 'text/html; charset=utf-8';
          add_header Access-Control-Allow-Origin *; 
          return 200 '{"msg":"/api/"}'; Test to make sure it hits}Copy the code

An ajax request

            $.ajax({
        type:'GET',                
url:"http://localhost/img/1.png",
Copy the code