enh: cookie auth

This commit is contained in:
Timothy J. Baek
2024-06-19 14:38:09 -07:00
parent 1b100660af
commit b36c525ebc
5 changed files with 42 additions and 12 deletions

View File

@@ -90,7 +90,8 @@ export const getSessionUser = async (token: string) => {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
},
credentials: 'include'
})
.then(async (res) => {
if (!res.ok) throw await res.json();

View File

@@ -92,15 +92,15 @@ export const getFileById = async (token: string, id: string) => {
return res;
};
export const getFileContentById = async (token: string, id: string) => {
export const getFileContentById = async (id: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/files/${id}/content`, {
method: 'GET',
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`
}
Accept: 'application/json'
},
credentials: 'include'
})
.then(async (res) => {
if (!res.ok) throw await res.json();

View File

@@ -104,7 +104,7 @@
type="button"
on:click={async () => {
if (file?.url) {
getFileContentById(localStorage.token, file.id).then((blob) => {
getFileContentById(file.id).then((blob) => {
if (blob) {
const url = URL.createObjectURL(blob);
window.open(url, '_blank').focus();