Ad

Cross-Origin Read Blocking (CORB) Blocked Cross-origin Response With MIME Type Application/json

- 1 answer

calling service from reactjs to spring boot. getting below error Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type application/json

react code:

fetch(URL, {method: 'GET',
            contentType: 'application/json',
            mode: 'no-cors'
          }).then (function (response) { return response.json()})
            .then(function (json) {debugger;console.log(json)})
            .catch(function (error) {debugger;console.log(error)});

spring code:

    @GetMapping(path="/user/{aid}", produces= {"application/json"})
    public Optional<User> getUser(@PathVariable int aid) {
        return userRepo.findById(aid);
    }

error message:

Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type application/json

Ad

Answer

You need to allow CORS from your spring code app. Hope this helps.Enabling Cross Origin Requests for a RESTful Web Service

Ad
source: stackoverflow.com
Ad