mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
4.8.5 perf app ui (#1845)
* list ui and layout * rename token key * app ui * ssr
This commit is contained in:
@@ -22,7 +22,7 @@ export const connectPg = async (): Promise<Pool> => {
|
||||
});
|
||||
|
||||
global.pgClient.on('error', async (err) => {
|
||||
console.log(err);
|
||||
addLog.error(`pg error`, err);
|
||||
global.pgClient?.end();
|
||||
global.pgClient = null;
|
||||
|
||||
@@ -36,6 +36,7 @@ export const connectPg = async (): Promise<Pool> => {
|
||||
console.log('pg connected');
|
||||
return global.pgClient;
|
||||
} catch (error) {
|
||||
addLog.error(`pg connect error`, error);
|
||||
global.pgClient?.end();
|
||||
global.pgClient = null;
|
||||
|
||||
|
@@ -85,7 +85,7 @@ export async function parseHeaderCert({
|
||||
async function authCookieToken(cookie?: string, token?: string) {
|
||||
// 获取 cookie
|
||||
const cookies = Cookie.parse(cookie || '');
|
||||
const cookieToken = token || cookies.token;
|
||||
const cookieToken = token || cookies[TokenName];
|
||||
|
||||
if (!cookieToken) {
|
||||
return Promise.reject(ERROR_ENUM.unAuthorization);
|
||||
@@ -198,12 +198,16 @@ export async function parseHeaderCert({
|
||||
}
|
||||
|
||||
/* set cookie */
|
||||
export const TokenName = 'fastgpt_token';
|
||||
export const setCookie = (res: NextApiResponse, token: string) => {
|
||||
res.setHeader('Set-Cookie', `token=${token}; Path=/; HttpOnly; Max-Age=604800; Samesite=Strict;`);
|
||||
res.setHeader(
|
||||
'Set-Cookie',
|
||||
`${TokenName}=${token}; Path=/; HttpOnly; Max-Age=604800; Samesite=Strict;`
|
||||
);
|
||||
};
|
||||
/* clear cookie */
|
||||
export const clearCookie = (res: NextApiResponse) => {
|
||||
res.setHeader('Set-Cookie', 'token=; Path=/; Max-Age=0');
|
||||
res.setHeader('Set-Cookie', `${TokenName}=; Path=/; Max-Age=0`);
|
||||
};
|
||||
|
||||
/* file permission */
|
||||
|
Reference in New Issue
Block a user