Skip to main content
edited tags
Link
Tim Stone
  • 4.7k
  • 3
  • 22
  • 32
'Stack Exchange' is the legal name; trademark capitalization; acronym capitalization; grammar.
Source Link

I'm currently using the API via javascript ajaxJavaScript AJAX calls and it all of a sudden stopped allowing CORS requests. I'm on localhost and I tried uploading my code to live and am still getting:

Access to XMLHttpRequest at 'https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ((' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ(( with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

Access to XMLHttpRequest at 
'https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ(('
from origin 'http://localhost:3000' has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested
resource.
Cross-Origin Read Blocking (CORB) blocked cross-origin response
https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ((
with MIME type application/json. See
https://www.chromestatus.com/feature/5629709824032768 for more
details.

The API has stopped allowing CORS requestsThe API has stopped allowing CORS requests

API endpoints do not set Access-Control-Allow-Origin, so CORS requests failAPI endpoints do not set Access-Control-Allow-Origin, so CORS requests fail

If I switch out my ajax urlAJAX URL for something like api.github.com/users/:username then I get a response.

Response header from api.stackexchange.comapi.stackexchange.com:

vs Response header from api.github.comapi.github.com:

Update 11/15/2019

It seems to work as normal again. I no longer get CORS errors or warnings.
According to this answer, it was due to SE porting their MVC to .NET core

I'm currently using the API via javascript ajax calls and it all of a sudden stopped allowing CORS requests. I'm on localhost and I tried uploading my code to live and am still getting:

Access to XMLHttpRequest at 'https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ((' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ(( with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

The API has stopped allowing CORS requests

API endpoints do not set Access-Control-Allow-Origin, so CORS requests fail

If I switch out my ajax url for something like api.github.com/users/:username then I get a response.

Response header from api.stackexchange.com:

vs Response header from api.github.com:

Update 11/15/2019

It seems to work as normal again. I no longer get CORS errors or warnings.
According to this answer, it was due to SE porting their MVC to .NET core

I'm currently using the API via JavaScript AJAX calls and it all of a sudden stopped allowing CORS requests. I'm on localhost and I tried uploading my code to live and am still getting:

Access to XMLHttpRequest at 
'https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ(('
from origin 'http://localhost:3000' has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested
resource.
Cross-Origin Read Blocking (CORB) blocked cross-origin response
https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ((
with MIME type application/json. See
https://www.chromestatus.com/feature/5629709824032768 for more
details.

The API has stopped allowing CORS requests

API endpoints do not set Access-Control-Allow-Origin, so CORS requests fail

If I switch out my AJAX URL for something like api.github.com/users/:username then I get a response.

Response header from api.stackexchange.com:

vs Response header from api.github.com:

added 117 characters in body
Source Link

I'm currently using the API via javascript ajax calls and it all of a sudden stopped allowing CORS requests. I'm on localhost and I tried uploading my code to live and am still getting:

Access to XMLHttpRequest at 'https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ((' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ(( with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

I see it has happened previously -

The API has stopped allowing CORS requests

API endpoints do not set Access-Control-Allow-Origin, so CORS requests fail

If I switch out my ajax url for something like api.github.com/users/:username then I get a response.

Response header from api.stackexchange.com:

Cache-Control: private
Content-Encoding: gzip
Content-Length: 15320
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Nov 2019 16:55:55 GMT
X-Content-Type-Options: nosniff

vs Response header from api.github.com:

Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Cache-Control: public, max-age=60, s-maxage=60
Content-Encoding: gzip
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Nov 2019 17:00:14 GMT
ETag: W/"01de5042f68702ea001f227ac84a26e5"
Last-Modified: Sun, 27 Oct 2019 07:40:00 GMT
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
Status: 304 Not Modified
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Vary: Accept
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-GitHub-Media-Type: github.v3
X-GitHub-Request-Id: EA28:258A2:16B35E8:1B423C5:5DCD881D
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 60
X-RateLimit-Reset: 1573754414
X-XSS-Protection: 1; mode=block

Update 11/15/2019

It seems to work as normal again. I no longer get CORS errors or warnings.
According to this answer, it was due to SE porting their MVC to .NET core

I'm currently using the API via javascript ajax calls and it all of a sudden stopped allowing CORS requests. I'm on localhost and I tried uploading my code to live and am still getting:

Access to XMLHttpRequest at 'https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ((' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ(( with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

I see it has happened previously -

The API has stopped allowing CORS requests

API endpoints do not set Access-Control-Allow-Origin, so CORS requests fail

If I switch out my ajax url for something like api.github.com/users/:username then I get a response.

Response header from api.stackexchange.com:

Cache-Control: private
Content-Encoding: gzip
Content-Length: 15320
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Nov 2019 16:55:55 GMT
X-Content-Type-Options: nosniff

vs Response header from api.github.com:

Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Cache-Control: public, max-age=60, s-maxage=60
Content-Encoding: gzip
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Nov 2019 17:00:14 GMT
ETag: W/"01de5042f68702ea001f227ac84a26e5"
Last-Modified: Sun, 27 Oct 2019 07:40:00 GMT
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
Status: 304 Not Modified
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Vary: Accept
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-GitHub-Media-Type: github.v3
X-GitHub-Request-Id: EA28:258A2:16B35E8:1B423C5:5DCD881D
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 60
X-RateLimit-Reset: 1573754414
X-XSS-Protection: 1; mode=block

I'm currently using the API via javascript ajax calls and it all of a sudden stopped allowing CORS requests. I'm on localhost and I tried uploading my code to live and am still getting:

Access to XMLHttpRequest at 'https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ((' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.stackexchange.com/2.2/search/advanced?pagesize=100&order=desc&sort=relevance&q=unit%20testing%20in%20react&answers=1&wiki=False&site=stackoverflow&key=g1ojUOeEFrEJKWLcC5yqhQ(( with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

I see it has happened previously -

The API has stopped allowing CORS requests

API endpoints do not set Access-Control-Allow-Origin, so CORS requests fail

If I switch out my ajax url for something like api.github.com/users/:username then I get a response.

Response header from api.stackexchange.com:

Cache-Control: private
Content-Encoding: gzip
Content-Length: 15320
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Nov 2019 16:55:55 GMT
X-Content-Type-Options: nosniff

vs Response header from api.github.com:

Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Cache-Control: public, max-age=60, s-maxage=60
Content-Encoding: gzip
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Thu, 14 Nov 2019 17:00:14 GMT
ETag: W/"01de5042f68702ea001f227ac84a26e5"
Last-Modified: Sun, 27 Oct 2019 07:40:00 GMT
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
Status: 304 Not Modified
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Vary: Accept
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-GitHub-Media-Type: github.v3
X-GitHub-Request-Id: EA28:258A2:16B35E8:1B423C5:5DCD881D
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 60
X-RateLimit-Reset: 1573754414
X-XSS-Protection: 1; mode=block

Update 11/15/2019

It seems to work as normal again. I no longer get CORS errors or warnings.
According to this answer, it was due to SE porting their MVC to .NET core

added 26 characters in body
Source Link
Loading
Source Link
Loading