No 'Access-Control-Allow-Origin' header is present on the requested resource. code example

Example 1: access-control-allow-origin

Access-Control-Allow-Origin: *

Example 2: ccess to XMLHttpRequest at 'http://127.0.0.1:5000/ has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

@app.route('your route', methods=['GET'])
def yourMethod(params):
    response = flask.jsonify({'some': 'data'})
    response.headers.add('Access-Control-Allow-Origin', '*')
    return response

Example 3: from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

@CrossOrigin(origins = "http://localhost:4200")
@GetMapping("/yourPath")

Example 4: Access to XMLHttpRequest at 'https://hddn92.skylinewebcams.com/1071speed-1606566964102.ts' from origin 'https://www.skylinewebcams.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

XMLHttpRequest cannot load http://localhost:9200/_all. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9100' is therefore not allowed access.

Tags:

Cpp Example