62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/**
|
|
* Teste simplificado de signup via Supabase
|
|
*/
|
|
|
|
import fetch from "node-fetch";
|
|
|
|
const SUPABASE_URL = "https://yuanqfswhberkoevtmfr.supabase.co";
|
|
const SUPABASE_ANON_KEY =
|
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inl1YW5xZnN3aGJlcmtvZXZ0bWZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ5NTQzNjksImV4cCI6MjA3MDUzMDM2OX0.g8Fm4XAvtX46zifBZnYVH4tVuQkqUH6Ia9CXQj4DztQ";
|
|
|
|
const timestamp = Date.now();
|
|
const testEmail = `pacienteteste${timestamp}@gmail.com`;
|
|
|
|
console.log("Testando signup com:", testEmail);
|
|
|
|
async function testSignup() {
|
|
const url = `${SUPABASE_URL}/auth/v1/signup`;
|
|
|
|
console.log("URL:", url);
|
|
|
|
const body = {
|
|
email: testEmail,
|
|
password: "Senha123!@#",
|
|
options: {
|
|
data: {
|
|
role: "paciente",
|
|
full_name: "Teste Automático",
|
|
},
|
|
},
|
|
};
|
|
|
|
console.log("Body:", JSON.stringify(body, null, 2));
|
|
|
|
try {
|
|
const response = await fetch(url, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
apikey: SUPABASE_ANON_KEY,
|
|
},
|
|
body: JSON.stringify(body),
|
|
});
|
|
|
|
console.log("Status:", response.status);
|
|
console.log("Headers:", Object.fromEntries(response.headers.entries()));
|
|
|
|
const text = await response.text();
|
|
console.log("Response (text):", text.substring(0, 500));
|
|
|
|
try {
|
|
const data = JSON.parse(text);
|
|
console.log("Response (JSON):", JSON.stringify(data, null, 2));
|
|
} catch (e) {
|
|
console.log("Não é JSON válido");
|
|
}
|
|
} catch (error) {
|
|
console.error("Erro:", error.message);
|
|
}
|
|
}
|
|
|
|
testSignup();
|