0

I am trying to connect my simple python server up to talk with my local safari browser. I have no issues at all with Google Chrome, but when I use Safari, I get "Fetch API cannot load xyz URL due to access control checks".

Here is my python code:

import json

import quart
import quart_cors
from quart import request

app = quart_cors.cors(quart.Quart(__name__), allow_origin="https://chat.openai.com")
app.config["CORS_ALLOW_HEADERS"] = "Content-Type"
app.config["CORS_EXPOSE_HEADERS"] = "Content-Type"

# Keep track of todo's. Does not persist if Python session is restarted.
_TODOS = {}

@app.post("/todos/<string:username>")
async def add_todo(username):
    request = await quart.request.get_json(force=True)
    if username not in _TODOS:
        _TODOS[username] = []
    _TODOS[username].append(request["todo"])
    return quart.Response(response='OK', status=200)

@app.get("/todos/<string:username>")
async def get_todos(username):
    return quart.Response(response=json.dumps(_TODOS.get(username, [])), status=200)

I tried doing the allow_origin="*" to no avail and added app.config["CORS_ALLOW_HEADERS"] as well but neither fixed the issue.

I also tried "Develop" -> "Disable Local File Restrictions" in my browser as well.

logankilpatrick
  • 13,148
  • 7
  • 44
  • 125

0 Answers0