mirror of
https://github.com/yawaflua/SusMarket.git
synced 2025-12-08 19:49:36 +02:00
Coded adding any domain of website in url request
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.1aa814f6.css",
|
||||
"main.js": "/static/js/main.0ec10cd6.js",
|
||||
"main.js": "/static/js/main.bd48089b.js",
|
||||
"static/media/scam-image.png": "/static/media/scam-image.c6c14289dc251ba2d2b1.png",
|
||||
"static/media/info-page__railth-avatar.png": "/static/media/info-page__railth-avatar.cbf11c43b5ef243b38c0.png",
|
||||
"static/media/add.webp": "/static/media/add.cd69f1e2a8c91109db0f.webp",
|
||||
@@ -14,10 +14,10 @@
|
||||
"static/media/rating__filled-star-icon.svg": "/static/media/rating__filled-star-icon.dc7d908d4d943b7f3b56.svg",
|
||||
"index.html": "/index.html",
|
||||
"main.1aa814f6.css.map": "/static/css/main.1aa814f6.css.map",
|
||||
"main.0ec10cd6.js.map": "/static/js/main.0ec10cd6.js.map"
|
||||
"main.bd48089b.js.map": "/static/js/main.bd48089b.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.1aa814f6.css",
|
||||
"static/js/main.0ec10cd6.js"
|
||||
"static/js/main.bd48089b.js"
|
||||
]
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SusMarket</title><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.0ec10cd6.js"></script><link href="/static/css/main.1aa814f6.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SusMarket</title><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.bd48089b.js"></script><link href="/static/css/main.1aa814f6.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,7 +11,9 @@ export default function CatalogMenu({ toggleCatalogMenu, onSelectCategory }: Cat
|
||||
const [categories, setCategories] = useState<Category[]>([]); // Состояние для хранения категорий
|
||||
|
||||
useEffect(() => { // При монтировании компонента запрашиваем категории с сервера
|
||||
axios.get('http://127.0.0.1:8000/api/get/category')
|
||||
const baseUrl = window.location.origin; // Получаем текущий домен сайта
|
||||
|
||||
axios.get(`${baseUrl}/api/get/category`)
|
||||
.then(response => {
|
||||
setCategories(response.data.categories);
|
||||
})
|
||||
|
||||
@@ -29,15 +29,17 @@ export default function LoginMenu({ toggleLoginMenu }: LoginMenuProps) {
|
||||
}, []);
|
||||
|
||||
const handleAuth = async (isRegistering: boolean) => { // Функция для обработки авторизации
|
||||
const baseUrl = window.location.origin; // Получаем текущий домен сайта
|
||||
|
||||
try {
|
||||
let response;
|
||||
if (isRegistering) {
|
||||
response = await axios.get(
|
||||
`http://127.0.0.1:8000/api/post/user?login=${encodeURIComponent(login)}&password=${encodeURIComponent(password)}`
|
||||
`${baseUrl}/api/post/user?login=${encodeURIComponent(login)}&password=${encodeURIComponent(password)}`
|
||||
);
|
||||
} else {
|
||||
response = await axios.get(
|
||||
`http://127.0.0.1:8000/api/get/user?login=${encodeURIComponent(login)}&password=${encodeURIComponent(password)}`
|
||||
`${baseUrl}/api/get/user?login=${encodeURIComponent(login)}&password=${encodeURIComponent(password)}`
|
||||
);
|
||||
if (response.data.user.length === 0) {
|
||||
alert('Пользователь не найден.');
|
||||
|
||||
@@ -13,7 +13,9 @@ export default function Review({ review }: ReviewProps) {
|
||||
const readableDate = new Date(review.date).toLocaleDateString('ru-RU'); // Преобразование даты в читабельную форму
|
||||
|
||||
useEffect(() => { // Получение имени пользователя по его ID
|
||||
axios.get(`http://127.0.0.1:8000/api/get/user/${review.user_id}`)
|
||||
const baseUrl = window.location.origin; // Получаем текущий домен сайта
|
||||
|
||||
axios.get(`${baseUrl}/api/get/user/${review.user_id}`)
|
||||
.then(response => {
|
||||
const user = response.data.user[0];
|
||||
setUserName(user.login);
|
||||
|
||||
@@ -50,6 +50,9 @@ export default function ReviewForm({ productId }: { productId: string }) {
|
||||
console.error('ID пользователя не найден!');
|
||||
return;
|
||||
}
|
||||
|
||||
const baseUrl = window.location.origin; // Получаем текущий домен сайта
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
params.append('commentary', review.text);
|
||||
@@ -60,7 +63,7 @@ export default function ReviewForm({ productId }: { productId: string }) {
|
||||
params.append('icon', review.image as string);
|
||||
}
|
||||
|
||||
await axios.post('http://127.0.0.1:8000/api/post/review', params, {
|
||||
await axios.post(`${baseUrl}/api/post/review`, params, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ export default function ProductPage() {
|
||||
};
|
||||
|
||||
useEffect(() => { // Получение продукта по его id
|
||||
axios.get('http://127.0.0.1:8000/api/get/products')
|
||||
const baseUrl = window.location.origin; // Получаем текущий домен сайта
|
||||
|
||||
axios.get(`${baseUrl}/api/get/products`)
|
||||
.then(response => {
|
||||
const productData = response.data.products.find(
|
||||
(item: Product) => item.id.toString() === id
|
||||
@@ -48,7 +50,9 @@ export default function ProductPage() {
|
||||
|
||||
useEffect(() => { // Получение рецензий по id продукта
|
||||
if (!isDataFetched) {
|
||||
axios.get(`http://127.0.0.1:8000/api/get/reviews/${id}`)
|
||||
const baseUrl = window.location.origin;
|
||||
|
||||
axios.get(`${baseUrl}/api/get/reviews/${id}`)
|
||||
.then(response => {
|
||||
const reviewsData = response.data.review;
|
||||
setReviews(reviewsData);
|
||||
|
||||
Reference in New Issue
Block a user