I want to solve the problem when I request a request in pythoanywhere the request requests path an addition to the domain and path
I just want to add the domain only, without the path, how is that?
Please note that I use cors in Django(django-cors-headers)
export function backendLookup(method, endpoint, callback, data) {
let jsonData;
if (data) {
jsonData = JSON.stringify(data);
}
const xhr = new XMLHttpRequest();
const url = `api${endpoint}`;
xhr.responseType = "json";
const csrftoken = getCookie("csrftoken");
xhr.open(method, url);
xhr.setRequestHeader("Content-Type", "application/json");
if (csrftoken) {
// xhr.setRequestHeader("HTTP_X_REQUESTED_WITH", "XMLHttpRequest")
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
xhr.onload = function () {
if (xhr.status === 403) {
const detail = xhr.response.detail;
if (detail === "Authentication credentials were not provided.") {
if (window.location.href.indexOf("login") === -1) {
window.location.href = "/login?showLoginRequired=true";
}
}
}
callback(xhr.response, xhr.status);
};
xhr.onerror = function (e) {
callback(
{
message: "The request was an error",
},
400
);
};
xhr.send(jsonData);
}
Meaning when I enter the link in the browser:
http://tweet.pythonanywhere.com/global/
The api backendLookup Automatically converts the domain and path:
http://tweet.pythonanywhere.com/global/api/tweets/
And I just want to add only the domain, how is that: