Skip to content

Commit e7a0836

Browse files
committed
fix: maitanance
1 parent 4173a98 commit e7a0836

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

public/sw.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ async function handleGitHubWriteRequest(request) {
9696
// Clone the request to add authorization headers
9797
const headers = new Headers(request.headers);
9898
headers.set('Accept', 'application/vnd.github.v3+json');
99-
headers.set('Authorization', `Bearer ${token}`);
99+
// Only set Authorization if not already present
100+
if (!headers.has('Authorization')) {
101+
headers.set('Authorization', `Bearer ${token}`);
102+
}
100103

101104
const authRequest = new Request(request, { headers });
102105

@@ -134,7 +137,7 @@ async function handleGitHubWriteRequest(request) {
134137
error: true,
135138
message: error.message
136139
}), {
137-
status: 500,
140+
status: 401,
138141
headers: { 'Content-Type': 'application/json' }
139142
});
140143
}
@@ -148,7 +151,7 @@ async function handleGitHubReadRequest(request) {
148151
// Create request with authorization
149152
const headers = new Headers();
150153
headers.set('Accept', 'application/vnd.github.v3+json');
151-
if (token) {
154+
if (token && !request.headers.has('Authorization')) {
152155
headers.set('Authorization', `Bearer ${token}`);
153156
}
154157

src/config/app.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export const config = {
1313
};
1414

1515
// Security validation
16-
if (config.github.token && !validateTokenSecurity(config.github.token)) {
16+
if (!config.github.token) {
17+
console.warn('Warning: VITE_API_KEY is not set. GitHub API requests will fail. Please set your GitHub token in .env file.');
18+
} else if (!validateTokenSecurity(config.github.token)) {
1719
console.warn('Warning: GitHub token may not meet security requirements');
1820
}
1921

src/pages/AdminPage.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ export function AdminPage() {
2222
return <Navigate to="/auth" replace />;
2323
}
2424

25-
if (user.username !== 'admin') {
26-
return <Navigate to="/" replace />;
27-
}
28-
2925
const handleSave = async () => {
3026
setIsSaving(true);
3127
try {
@@ -48,9 +44,9 @@ export function AdminPage() {
4844
<ArrowLeft className="w-5 h-5" />
4945
</button>
5046
<div>
51-
<h1 className="text-2xl font-bold">Админ-панель</h1>
47+
<h1 className="text-2xl font-bold">Панель настроек</h1>
5248
<p className="text-sm text-gray-600 dark:text-gray-400 mt-1">
53-
Здесь доступны настройки только для пользователя <span className="font-semibold">admin</span>.
49+
Здесь доступны настройки сайта.
5450
</p>
5551
</div>
5652
</div>

0 commit comments

Comments
 (0)