mirror of
https://github.com/wowlikon/LiB.git
synced 2026-02-03 20:31:09 +00:00
Исправление mixed content
This commit is contained in:
@@ -96,10 +96,10 @@ async def book(request: Request, book_id: int):
|
||||
return templates.TemplateResponse(request, "book.html")
|
||||
|
||||
|
||||
@router.get("/auth", include_in_schema=False)
|
||||
async def auth(request: Request):
|
||||
"""Эндпоинт страницы авторизации"""
|
||||
return templates.TemplateResponse(request, "auth.html")
|
||||
@router.get("/auth", include_in_schema=False)
|
||||
async def auth(request: Request):
|
||||
"""Эндпоинт страницы авторизации"""
|
||||
return templates.TemplateResponse(request, "auth.html")
|
||||
|
||||
|
||||
@router.get("/profile", include_in_schema=False)
|
||||
|
||||
@@ -53,7 +53,12 @@ const Utils = {
|
||||
};
|
||||
|
||||
const Api = {
|
||||
getBaseUrl() {
|
||||
return window.location.origin;
|
||||
},
|
||||
|
||||
async request(endpoint, options = {}) {
|
||||
const fullUrl = this.getBaseUrl() + endpoint;
|
||||
const token = localStorage.getItem("access_token");
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
@@ -67,14 +72,14 @@ const Api = {
|
||||
const config = { ...options, headers };
|
||||
|
||||
try {
|
||||
const response = await fetch(endpoint, config);
|
||||
const response = await fetch(fullUrl, config);
|
||||
|
||||
if (response.status === 401) {
|
||||
const refreshed = await Auth.tryRefresh();
|
||||
if (refreshed) {
|
||||
headers["Authorization"] =
|
||||
`Bearer ${localStorage.getItem("access_token")}`;
|
||||
const retryResponse = await fetch(endpoint, { ...options, headers });
|
||||
const retryResponse = await fetch(fullUrl, { ...options, headers });
|
||||
if (retryResponse.ok) {
|
||||
return retryResponse.json();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user