Supabase returning 400 on PUT auth v1 user
Everything was working fine yesterday, I didn't touch my code or anything, but today when using
Not using prisma.
Client code: (React 17 with Next 12)
Server API log:
supabase-js@1.35.4supabase-js@1.35.4, Supabase returned a 400 error on PUT /auth/v1/userPUT /auth/v1/user. I was trying to edit user metadata in my database.Not using prisma.
Client code: (React 17 with Next 12)
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [slug, setSlug] = useState("");
const [tags, setTags] = useState<string[]>([]);
const [content, setContent] = useState("");
const [contentMode, setContentMode] = useState("code");
const [MDXContent, setMDXContent] = useState<MDXContent>();
useEffect(() => {
const interval = setInterval(async () => {
if (!title && !description && !slug && !tags.length && !content) return;
if (title === supabase.auth.user()?.user_metadata.title) return;
if (description === supabase.auth.user()?.user_metadata.description)
return;
if (slug === supabase.auth.user()?.user_metadata.slug) return;
if (tags === supabase.auth.user()?.user_metadata.tags) return;
if (content === supabase.auth.user()?.user_metadata.content) return;
const { error } = await supabase.auth.update({
data: {
blogDraft: {
title,
description,
slug,
tags,
content,
},
},
});
if (error) {
console.error(error);
toast.error(
"An unexpected error occurred while saving a draft. Refer to the console for details."
);
}
}, 5000);
return () => clearInterval(interval);
}, [title, description, slug, tags, content]); const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [slug, setSlug] = useState("");
const [tags, setTags] = useState<string[]>([]);
const [content, setContent] = useState("");
const [contentMode, setContentMode] = useState("code");
const [MDXContent, setMDXContent] = useState<MDXContent>();
useEffect(() => {
const interval = setInterval(async () => {
if (!title && !description && !slug && !tags.length && !content) return;
if (title === supabase.auth.user()?.user_metadata.title) return;
if (description === supabase.auth.user()?.user_metadata.description)
return;
if (slug === supabase.auth.user()?.user_metadata.slug) return;
if (tags === supabase.auth.user()?.user_metadata.tags) return;
if (content === supabase.auth.user()?.user_metadata.content) return;
const { error } = await supabase.auth.update({
data: {
blogDraft: {
title,
description,
slug,
tags,
content,
},
},
});
if (error) {
console.error(error);
toast.error(
"An unexpected error occurred while saving a draft. Refer to the console for details."
);
}
}, 5000);
return () => clearInterval(interval);
}, [title, description, slug, tags, content]);Server API log:
- Status: 400
- Method: PUT
- Timestamp: 1663368211264000
- Client: supabase-js/1.35.4
- Referer: https://www.godder.xyz/
Request body:{ "cf": [ { "asOrganization": "Verizon Fios", "asn": 701, "botManagement": [ { "score": 98, "staticResource": false, "verifiedBot": false } ], "city": "XXX", "clientAcceptEncoding": "gzip, deflate, br", "clientTcpRtt": null, "clientTrustScore": 98, "colo": "XXX", "continent": "NA", "country": "US", "edgeRequestKeepAliveStatus": 1, "httpProtocol": "HTTP/3", "isEUCountry": null, "latitude": "XXX", "longitude": "XXX", "metroCode": "XXX", "postalCode": "XXX", "region": "XXX", "regionCode": "XXX", "requestPriority": null, "timezone": "America/New_York", "tlsCipher": "AEAD-AES128-GCM-SHA256", "tlsClientAuth": [ { "certPresented": "0", "certRevoked": "0", "certVerified": "NONE" } ], "tlsExportedAuthenticator": [ { "clientFinished": "XXX", "clientHandshake": "XXX", "serverFinished": "XXX", "serverHandshake": "XXX" } ], "tlsVersion": "TLSv1.3" } ], "headers": [ { "accept": "*/*", "cf_connecting_ip": "XXX", "cf_ipcountry": "US", "cf_ray": "74bd1f181ed67fed", "content_length": "518", "content_range": null, "content_type": "text/plain;charset=UTF-8", "date": null, "host": "mqzswyobtehomvpicltf.supabase.co", "referer": "https://www.godder.xyz/", "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "x_client_info": "supabase-js/1.35.4", "x_forwarded_proto": "https", "x_forwarded_user_agent": null, "x_real_ip": "XXX" } ], "host": "mqzswyobtehomvpicltf.supabase.co", "method": "PUT", "path": "/auth/v1/user", "protocol": "https:", "sb": [ { "auth_user": "b9d73cee-2922-4daa-9cfb-bb6701f65ce3" } ], "search": null, "url": "https://mqzswyobtehomvpicltf.supabase.co/auth/v1/user" }{ "cf": [ { "asOrganization": "Verizon Fios", "asn": 701, "botManagement": [ { "score": 98, "staticResource": false, "verifiedBot": false } ], "city": "XXX", "clientAcceptEncoding": "gzip, deflate, br", "clientTcpRtt": null, "clientTrustScore": 98, "colo": "XXX", "continent": "NA", "country": "US", "edgeRequestKeepAliveStatus": 1, "httpProtocol": "HTTP/3", "isEUCountry": null, "latitude": "XXX", "longitude": "XXX", "metroCode": "XXX", "postalCode": "XXX", "region": "XXX", "regionCode": "XXX", "requestPriority": null, "timezone": "America/New_York", "tlsCipher": "AEAD-AES128-GCM-SHA256", "tlsClientAuth": [ { "certPresented": "0", "certRevoked": "0", "certVerified": "NONE" } ], "tlsExportedAuthenticator": [ { "clientFinished": "XXX", "clientHandshake": "XXX", "serverFinished": "XXX", "serverHandshake": "XXX" } ], "tlsVersion": "TLSv1.3" } ], "headers": [ { "accept": "*/*", "cf_connecting_ip": "XXX", "cf_ipcountry": "US", "cf_ray": "74bd1f181ed67fed", "content_length": "518", "content_range": null, "content_type": "text/plain;charset=UTF-8", "date": null, "host": "mqzswyobtehomvpicltf.supabase.co", "referer": "https://www.godder.xyz/", "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "x_client_info": "supabase-js/1.35.4", "x_forwarded_proto": "https", "x_forwarded_user_agent": null, "x_real_ip": "XXX" } ], "host": "mqzswyobtehomvpicltf.supabase.co", "method": "PUT", "path": "/auth/v1/user", "protocol": "https:", "sb": [ { "auth_user": "b9d73cee-2922-4daa-9cfb-bb6701f65ce3" } ], "search": null, "url": "https://mqzswyobtehomvpicltf.supabase.co/auth/v1/user" }