Uploaded image for project: 'Mojang Web Services'
  1. Mojang Web Services
  2. WEB-1587

CORS header missing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • Icon: Normal Normal
    • None
    • None

      The API at address https://api.mojang.com/users/profiles/minecraft/<username> doesn't respond with CORS headers, particularly Access-Control-Allow-Origin: * is missing. Without this header modern browsers will discard the response and create an error message.

      In the Developer Tools of Firefox this looks like:

      fetch('https://api.mojang.com/users/profiles/minecraft/test').then(console.log)

      Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.mojang.com/users/profiles/minecraft/test. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
      TypeError: NetworkError when attempting to fetch resource.
       
      To set mode:no-cors is not an option because in this case the browsers exchange the response with an opaque one, which is basically empty.
      fetch('https://api.mojang.com/users/profiles/minecraft/test', {mode:'no-cors'}).then(console.log)
       
      Currently the only way to use this API with browsers is to set up an additional server as a proxy that adds this header. But that's not what I want. In times of GDPR I'm not interested to run such a server or to use a third party server for a web application that should only run in the browser. Please consider to add the mentioned header.
       

            Unassigned Unassigned
            flachdachs Flachdachs
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: