fix: prevent cached settings responses (#951)
This commit is contained in:
@@ -4,6 +4,13 @@ import { applyOutboundProxyEnv } from "@/lib/network/outboundProxy";
|
|||||||
import { resetComboRotation } from "open-sse/services/combo.js";
|
import { resetComboRotation } from "open-sse/services/combo.js";
|
||||||
import bcrypt from "bcryptjs";
|
import bcrypt from "bcryptjs";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
export const revalidate = 0;
|
||||||
|
|
||||||
|
const SETTINGS_RESPONSE_HEADERS = {
|
||||||
|
"Cache-Control": "no-store"
|
||||||
|
};
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
const settings = await getSettings();
|
const settings = await getSettings();
|
||||||
@@ -17,7 +24,7 @@ export async function GET() {
|
|||||||
enableRequestLogs,
|
enableRequestLogs,
|
||||||
enableTranslator,
|
enableTranslator,
|
||||||
hasPassword: !!password
|
hasPassword: !!password
|
||||||
});
|
}, { headers: SETTINGS_RESPONSE_HEADERS });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error getting settings:", error);
|
console.log("Error getting settings:", error);
|
||||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||||
@@ -77,7 +84,7 @@ export async function PATCH(request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { password, ...safeSettings } = settings;
|
const { password, ...safeSettings } = settings;
|
||||||
return NextResponse.json(safeSettings);
|
return NextResponse.json(safeSettings, { headers: SETTINGS_RESPONSE_HEADERS });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error updating settings:", error);
|
console.log("Error updating settings:", error);
|
||||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||||
|
|||||||
Reference in New Issue
Block a user