Но при работе из приложения заголовки никуда не приходят.
Я уже настроил cors:
Код: Выделить всё
from flask_cors import CORS
app = Flask(__name__)
CORS(app, resources={r"*": {"origins": "http://localhost:4200"}},
allow_headers=["Authorization", "Content-Type", "X-custom-1", "X-custom-2"],
methods=["GET", "POST", "OPTIONS"])
Код: Выделить всё
$.ajax({
url: 'http://localhost:5000/api/some_endpoint',
method: 'POST',
headers: {
'X-custom-1': '123',
'X-custom-2': 'abc',
'Authorization': `Bearer ${access_token)}`
},
data: JSON.stringify({
key1: 'value1',
key2: 'value2'
}),
contentType: 'application/json'
});
Подробнее здесь: https://stackoverflow.com/questions/793 ... -with-curl
Мобильная версия