mirror of
https://gitlab.com/foxixus/neomovies.git
synced 2025-10-28 01:48:50 +05:00
Bug fix
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://neomovies-test-api.vercel.app';
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.neomovies.ru';
|
||||||
|
|
||||||
// Создание экземпляра Axios с базовыми настройками
|
// Создание экземпляра Axios с базовыми настройками
|
||||||
export const neoApi = axios.create({
|
export const neoApi = axios.create({
|
||||||
@@ -15,7 +15,14 @@ export const neoApi = axios.create({
|
|||||||
neoApi.interceptors.request.use(
|
neoApi.interceptors.request.use(
|
||||||
(config) => {
|
(config) => {
|
||||||
// Получение токена из localStorage или другого хранилища
|
// Получение токена из localStorage или другого хранилища
|
||||||
const token = localStorage.getItem('token');
|
let token: string | null = null;
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
try {
|
||||||
|
token = localStorage.getItem('token');
|
||||||
|
} catch {
|
||||||
|
token = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers.Authorization = `Bearer ${token}`;
|
config.headers.Authorization = `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user