Я пытаюсь передать защиту моего API с помощью файла htaccess, поэтому при попытке отправить запрос аутентификации в запросе на получение Axios я получаю ошибку CORS и ошибку 404.
Это мой запрос Axios GET:
Код: Выделить всё
getData = async () => {
const username = "xyxyx";
const pass = "xyxy";
const basicAuth = "Basic " + Buffer.from(username +":"+pass).toString('base64');
console.log("BasicAuth::", basicAuth);
try {
const {data} = await axios.get(UrlApi.Url, {
// mode: "no-cors" ,
// headers : {
// 'Authorization': basicAuth,
// }
// mode: "no-cors",
// allowCredentials: true,
auth: {
username: "xyxyx",
password: "xyxy"
}
});
Ниже приведен index.php моего API (который я не писал)
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/71277485/preflight-cors-error-followed-by-404-error[/url]
Мобильная версия