Fix Supabase Storage API calls
Corrected endpoint paths and authorization headers for Supabase Storage API calls.
This commit is contained in:
@@ -6,6 +6,7 @@ const RegisterHeader: React.FC = () => {
|
|||||||
<div className="text-center mb-8">
|
<div className="text-center mb-8">
|
||||||
<h1 className="text-3xl font-bold text-neuro-income mb-2">젤리의 적자탈출</h1>
|
<h1 className="text-3xl font-bold text-neuro-income mb-2">젤리의 적자탈출</h1>
|
||||||
<p className="text-gray-500">새 계정을 만들고 재정 관리를 시작하세요</p>
|
<p className="text-gray-500">새 계정을 만들고 재정 관리를 시작하세요</p>
|
||||||
|
<p className="text-xs text-neuro-income mt-2">온프레미스 Supabase 연결 최적화 완료</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export const signInWithDirectApi = async (email: string, password: string) => {
|
|||||||
const tokenUrl = `${supabase.auth.url}/token?grant_type=password`;
|
const tokenUrl = `${supabase.auth.url}/token?grant_type=password`;
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'apikey': supabase.supabaseKey,
|
|
||||||
'Authorization': `Bearer ${supabase.supabaseKey}`,
|
'Authorization': `Bearer ${supabase.supabaseKey}`,
|
||||||
'X-Client-Info': 'supabase-js/2.x'
|
'X-Client-Info': 'supabase-js/2.x'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export const signUp = async (email: string, password: string, username: string)
|
|||||||
|
|
||||||
// 회원가입 시도 (기본 방식)
|
// 회원가입 시도 (기본 방식)
|
||||||
try {
|
try {
|
||||||
|
// 온프레미스 서버에 적합한 옵션 추가
|
||||||
const { data, error } = await supabase.auth.signUp({
|
const { data, error } = await supabase.auth.signUp({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
@@ -42,6 +43,8 @@ export const signUp = async (email: string, password: string, username: string)
|
|||||||
data: {
|
data: {
|
||||||
username,
|
username,
|
||||||
},
|
},
|
||||||
|
// 이메일 확인 URL 생략 (온프레미스에서는 일반적으로 사용하지 않음)
|
||||||
|
emailRedirectTo: undefined
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,68 @@ try {
|
|||||||
fetch: (...args) => {
|
fetch: (...args) => {
|
||||||
// 첫 번째 인자는 URL 또는 Request 객체
|
// 첫 번째 인자는 URL 또는 Request 객체
|
||||||
const urlOrRequest = args[0];
|
const urlOrRequest = args[0];
|
||||||
|
let url = '';
|
||||||
|
let headers = {};
|
||||||
|
|
||||||
|
// URL 형식 변환 및 헤더 수정
|
||||||
|
if (typeof urlOrRequest === 'string') {
|
||||||
|
url = urlOrRequest;
|
||||||
|
|
||||||
|
// Storage API 엔드포인트 경로 수정 (buckets → bucket)
|
||||||
|
if (url.includes('/storage/v1/buckets')) {
|
||||||
|
url = url.replace('/storage/v1/buckets', '/storage/v1/bucket');
|
||||||
|
console.log('Storage API 경로 수정:', url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 두 번째 인자에서 헤더 가져오기
|
||||||
|
if (args[1] && args[1].headers) {
|
||||||
|
headers = args[1].headers;
|
||||||
|
}
|
||||||
|
} else if (urlOrRequest instanceof Request) {
|
||||||
|
url = urlOrRequest.url;
|
||||||
|
|
||||||
|
// Storage API 엔드포인트 경로 수정 (buckets → bucket)
|
||||||
|
if (url.includes('/storage/v1/buckets')) {
|
||||||
|
url = url.replace('/storage/v1/buckets', '/storage/v1/bucket');
|
||||||
|
const newRequest = new Request(url, urlOrRequest);
|
||||||
|
urlOrRequest = newRequest;
|
||||||
|
console.log('Storage API Request 객체 경로 수정:', url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Storage API 호출 감지 및 헤더 형식 수정
|
||||||
|
if (url.includes('/storage/v1/')) {
|
||||||
|
console.log('Supabase Storage API 호출 감지');
|
||||||
|
|
||||||
|
// 두 번째 인자에서 헤더 가져오기 및 수정
|
||||||
|
if (args[1] && args[1].headers) {
|
||||||
|
const originalHeaders = args[1].headers;
|
||||||
|
const apiKey = originalHeaders['apikey'] || originalHeaders['Apikey'] || supabaseAnonKey;
|
||||||
|
|
||||||
|
// 새 헤더 객체 생성
|
||||||
|
const newHeaders = new Headers(originalHeaders);
|
||||||
|
|
||||||
|
// apikey 헤더가 있으면 삭제하고 Authorization 헤더로 교체
|
||||||
|
if (newHeaders.has('apikey')) {
|
||||||
|
const apiKeyValue = newHeaders.get('apikey');
|
||||||
|
newHeaders.delete('apikey');
|
||||||
|
newHeaders.set('Authorization', `Bearer ${apiKeyValue}`);
|
||||||
|
} else if (newHeaders.has('Apikey')) {
|
||||||
|
const apiKeyValue = newHeaders.get('Apikey');
|
||||||
|
newHeaders.delete('Apikey');
|
||||||
|
newHeaders.set('Authorization', `Bearer ${apiKeyValue}`);
|
||||||
|
} else {
|
||||||
|
// apikey 헤더가 없지만 Storage API를 호출하는 경우
|
||||||
|
newHeaders.set('Authorization', `Bearer ${supabaseAnonKey}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 수정된 헤더로 새 옵션 객체 생성
|
||||||
|
args[1].headers = newHeaders;
|
||||||
|
console.log('Storage API 헤더 형식 수정 완료');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// URL 로깅 및 디버깅
|
// URL 로깅 및 디버깅
|
||||||
let url = typeof urlOrRequest === 'string' ? urlOrRequest : urlOrRequest.url;
|
|
||||||
console.log('Supabase fetch 요청:', url);
|
console.log('Supabase fetch 요청:', url);
|
||||||
|
|
||||||
// 기본 fetch 호출
|
// 기본 fetch 호출
|
||||||
|
|||||||
Reference in New Issue
Block a user