I have a backend developed using Quart that uses the quart_cors lib to avoid CORS problems. Everything was working fine, but when I try to add Application Insights from Microsoft Azure solutions the cors error returns.
This is the backend code:
app = cors(app, allow_origin="*", allow_headers=["Content-Type"])
Routes.py:
@app.before_request
async def before_request():
# Start tracing this request
print("TEST")
request.tracer = Tracer(exporter=AzureExporter(connection_string=os.getenv('CONNECTION_STRING_APPLICATION_INSIGHTS')), sampler=ProbabilitySampler(rate=1.0))
request.tracer.span(name=request.path)
@app.after_request
async def after_request(response):
# End tracing this request
print("TEST 2")
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Headers'] = 'Content-Type'
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
request.tracer.finish()
return response
It returns like this on my react frontend application: