mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
enh: cookie auth
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user