Ask coding questions

← Back to all posts
CORS blocking request when using custom domain.
h
xfinnbar (21)
Access to XMLHttpRequest at 'https://textworld.xfinnbar.repl.co/api/create_page' from origin 'https://textworld.tk' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

The error only appears when using my custom domain, https://textworld.tk, instead of the repl.co one

Answered by Coder100 (17018) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (17018)

add this to ur code like:

from flask import Flask
from flask_cors import CORS

app = Flask(__name__)
CORS(app)

@app.route("/")
def helloWorld():
  ...

...

so easy

xxpertHacker (861)

Just send COORS HTTP headers.