AUTH SETUP INSTRUCTION
# 🔐 Инструкция по настройке аутентификации
## Проблема
Frontend получает 401 ошибку при запросах к API, даже если пользователь вошел в систему.
## Причина
1. Токен доступа (access_token) истек
2. Frontend не использует refresh_token для обновления токена
3. Миграция RLS не была применена к базе данных
## Решение
### Шаг 1: Применить миграцию RLS (ОБЯЗАТЕЛЬНО!)
1. Откройте Supabase Dashboard: https://app.supabase.com
2. Выберите ваш проект (hgjbjccpeirwrabbcjhr)
3. Перейдите в **SQL Editor**
4. Скопируйте и выполните содержимое файла:
```
backend/database/migrations/006_fix_rls_and_auth.sql
```
**Важно:** Без этого шага аутентификация не будет работать корректно!
### Шаг 2: Очистить localStorage и перезайти
1. Откройте браузер
2. Нажмите F12 → Application → Local Storage → http://localhost:5174
3. Удалите все ключи:
- `access_token`
- `refresh_token`
- `user`
4. Обновите страницу
5. Зарегистрируйте нового пользователя или войдите
### Шаг 3: Проверить работу API
После входа откройте консоль разработчика (F12) и выполните:when to use it
Community prompt sourced from the open-source GitHub repo Ovladimirovich/pad-plus-ai (Apache-2.0). A "AUTH SETUP INSTRUCTION" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
codingcommunitydeveloper
source
Ovladimirovich/pad-plus-ai · Apache-2.0
more in Coding
Coding✓ tested
Senior code review (strict mode)
senior staff engineer running a merciless but fair review
Coding✓ tested
Debug by hypothesis, not by guessing
debugging partner who forms theories before touching code
Coding✓ tested
Generate tests from described behavior
test engineer who writes tests that would actually catch regressions