Merge pull request #1855 from appwrite/fix-nginx-cache-headers

Enable Sentry again and future-proof nginx caching configuration
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2025-05-19 00:57:22 +02:00
commit 52f3dedeeb
36 files changed
+91 -166

No files matched your search

+17 -26
View File
@@ -1,40 +1,31 @@
map $sent_http_content_type $cc_header {
default "public, max-age=31536000";
text/html "no-cache";
}
server {
listen 80;
server_name localhost;
# serve compressed file if filename.gz exists
gzip_static on;
location = /console/service-worker.js {
root /usr/share/nginx/html;
add_header Cache-Control "public, max-age=30" always;
}
# Set root for all locations
root /usr/share/nginx/html;
location = /console/_app/env.js {
root /usr/share/nginx/html;
add_header Cache-Control "public, max-age=30" always;
# Security headers for all locations
add_header X-UA-Compatible "IE=Edge";
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block;";
add_header X-Content-Type-Options nosniff;
# Only cache files in /console/_app/immutable/ for 1 year
location /console/_app/immutable/ {
try_files $uri =404;
expires 1y;
add_header Pragma public;
add_header Cache-Control "public";
}
# All other /console requests (no cache)
location /console {
root /usr/share/nginx/html;
index index.html index.htm;
index index.html index.html;
try_files $uri /console/index.html;
add_header Cache-Control $cc_header always;
# Deny IE browsers from going into quirks mode
add_header X-UA-Compatible "IE=Edge";
# X-Frame-Options is to prevent from clickJacking attack
add_header X-Frame-Options SAMEORIGIN;
# This header enables the Cross-site scripting (XSS) filter
add_header X-XSS-Protection "1; mode=block;";
# disable content-type sniffing on some browsers.
add_header X-Content-Type-Options nosniff;
}
location / {
+9 -9
View File
@@ -1,15 +1,15 @@
// import * as Sentry from '@sentry/sveltekit';
// import { isCloud, isProd } from '$lib/system';
import * as Sentry from '@sentry/sveltekit';
import { isCloud, isProd } from '$lib/system';
import { AppwriteException } from '@appwrite.io/console';
import type { HandleClientError } from '@sveltejs/kit';
// Sentry.init({
// enabled: isCloud && isProd,
// dsn: 'https://c7ce178bdedd486480317b72f282fd39@o1063647.ingest.us.sentry.io/4504158071422976',
// tracesSampleRate: 1,
// replaysSessionSampleRate: 0,
// replaysOnErrorSampleRate: 0
// });
Sentry.init({
enabled: isCloud && isProd,
dsn: 'https://c7ce178bdedd486480317b72f282fd39@o1063647.ingest.us.sentry.io/4504158071422976',
tracesSampleRate: 1,
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0
});
export const handleError: HandleClientError = ({ error, message, status }) => {
console.error(error);
+11 -11
View File
@@ -1,14 +1,14 @@
// import { sequence } from '@sveltejs/kit/hooks';
// import { handleErrorWithSentry, sentryHandle } from '@sentry/sveltekit';
// import * as Sentry from '@sentry/sveltekit';
// import { isCloud, isProd } from '$lib/system';
import { sequence } from '@sveltejs/kit/hooks';
import { handleErrorWithSentry, sentryHandle } from '@sentry/sveltekit';
import * as Sentry from '@sentry/sveltekit';
import { isCloud, isProd } from '$lib/system';
// Sentry.init({
// enabled: isCloud && isProd,
// dsn: 'https://c7ce178bdedd486480317b72f282fd39@o1063647.ingest.us.sentry.io/4504158071422976',
// tracesSampleRate: 1.0
// });
Sentry.init({
enabled: isCloud && isProd,
dsn: 'https://c7ce178bdedd486480317b72f282fd39@o1063647.ingest.us.sentry.io/4504158071422976',
tracesSampleRate: 1.0
});
// export const handle = sequence(sentryHandle());
export const handle = sequence(sentryHandle());
// export const handleError = handleErrorWithSentry();
export const handleError = handleErrorWithSentry();
-2
View File
@@ -167,8 +167,6 @@
}
$: extension = allowedExtension === '*' ? mimeTypeQuery : `.${allowedExtension}`;
$: console.log(`Allowed extensions: ${allowedExtension}, MimeType: ${mimeTypeQuery}`);
</script>
<svelte:document on:visibilitychange={handleVisibilityChange} />
-1
View File
@@ -133,7 +133,6 @@ export function setStatusCodeFilter(filter: FilterData, columns: Column[]) {
tag: `**${filter.title}** is **${codeRange.label}**`,
value: statusCodeTag.value
};
console.log(codeRange);
parsedTags.update((tags) => {
tags.push(newTag);
return tags;
@@ -43,7 +43,6 @@
const content = await sdk
.forProject(page.params.region, page.params.project)
.vcs.getRepositoryContents($installation.$id, $repository.id, currentPath);
// console.log(content);
directories[0].fileCount = content.contents?.length ?? 0;
directories[0].children = content.contents
.filter((e) => e.isDirectory)
@@ -55,10 +54,9 @@
loading: false
}));
currentDir = directories[0];
// console.log(directories);
isLoading = false;
} catch (e) {
console.log(e);
} catch {
return;
}
});
@@ -85,7 +83,7 @@
const content = await sdk
.forProject(page.params.region, page.params.project)
.vcs.getRepositoryContents($installation.$id, $repository.id, path);
// console.log(content);
const fileCount = content.contents?.length ?? 0;
const contentDirectories = content.contents.filter((e) => e.isDirectory);
-5
View File
@@ -36,7 +36,6 @@ export async function processFileList(files: FileList): Promise<FileData[]> {
buffer: buffer
};
} catch (e) {
// console.log(file);
return null;
}
});
@@ -46,7 +45,6 @@ export async function processFileList(files: FileList): Promise<FileData[]> {
export async function gzipUpload(files: FileList) {
let uploadFile: File;
const tick = performance.now();
if (!files?.length) return;
// If the file is a tar.gz file, then return it as is
@@ -79,9 +77,6 @@ export async function gzipUpload(files: FileList) {
});
}
}
console.log(uploadFile);
const tock = performance.now();
console.log('Time taken to process files:', tock - tick);
return uploadFile;
}
@@ -20,7 +20,6 @@
async function addDomain() {
try {
domain = await sdk.forConsole.domains.create(page.params.organization, domainName);
console.log(domain);
invalidate(Dependencies.DOMAINS);
} catch (error) {
addNotification({
@@ -31,7 +31,6 @@
try {
domain = await sdk.forConsole.domains.updateNameservers(domain.$id);
verified = domain.nameservers === 'Appwrite';
console.log(domain);
} catch (error) {
addNotification({
type: 'error',
@@ -39,8 +38,6 @@
});
}
}
$: console.log($consoleVariables._APP_DOMAINS_NAMESERVERS);
</script>
<Fieldset legend="Verification">
@@ -12,8 +12,6 @@
export let runtimes: Models.RuntimeList;
$: selectedRuntime = runtimes?.runtimes.find((r) => r.$id === runtime);
$: console.log(runtimes);
</script>
<Card padding="s" radius="s">
@@ -15,8 +15,6 @@
checked: true
};
});
$: console.log(selectedScopes);
</script>
<Fieldset legend="Permissions">
@@ -58,9 +58,8 @@
}
return sorted;
} catch (error) {
console.log(installations);
console.log(error);
} catch {
return;
}
}
@@ -121,8 +120,6 @@
error = e.message;
}
}
$: console.log($repository);
</script>
<Modal title="Create Git deployment" bind:show onSubmit={createDeployment} bind:error>
@@ -104,8 +104,8 @@
undefined
);
await invalidate(Dependencies.FUNCTION);
} catch (error) {
console.log(error);
} catch {
return;
}
}
</script>
@@ -152,8 +152,8 @@
undefined
);
await invalidate(Dependencies.FUNCTION);
} catch (error) {
console.log(error);
} catch {
return;
}
}
</script>
@@ -7,7 +7,6 @@
import { Button, Form, InputText } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { func } from '../store';
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
import { specificationsList } from '$lib/stores/specifications';
@@ -16,29 +15,20 @@
import { Layout, Typography } from '@appwrite.io/pink-svelte';
import Link from '$lib/elements/link.svelte';
export let runtimesList: Models.RuntimeList;
const functionId = page.params.function;
let runtime: string = $func.runtime;
let entrypoint = $func.entrypoint;
export let runtimesList: Models.RuntimeList;
let { runtime, entrypoint, specification } = $func;
let options = [];
let specificationOptions = [];
onMount(async () => {
let allowedSpecifications = (await $specificationsList).specifications;
options = runtimesList.runtimes.map((runtime) => ({
label: `${runtime.name} - ${runtime.version}`,
value: runtime.$id
}));
specificationOptions = allowedSpecifications.map((size) => ({
label:
`${size.cpus} CPU, ${size.memory} MB RAM` +
(!size.enabled ? ` (Upgrade to use this)` : ''),
value: size.slug,
disabled: !size.enabled
}));
});
const options = runtimesList.runtimes.map((runtime) => ({
label: `${runtime.name} - ${runtime.version}`,
value: runtime.$id
}));
const specificationOptions = $specificationsList.specifications.map((size) => ({
label:
`${size.cpus} CPU, ${size.memory} MB RAM` +
(!size.enabled ? ` (Upgrade to use this)` : ''),
value: size.slug
}));
async function updateRuntime() {
try {
@@ -108,12 +98,12 @@
id="entrypoint"
required
placeholder="Enter entrypoint"
bind:value={$func.entrypoint} />
bind:value={entrypoint} />
<InputSelect
label="CPU and memory"
id="size"
placeholder="Select runtime specification"
bind:value={$func.specification}
bind:value={specification}
options={specificationOptions} />
</Layout.Stack>
</svelte:fragment>
@@ -99,7 +99,6 @@
: capitalize(useCase)}
checked={isChecked(useCase)}
on:change={(e) => {
console.log(useCase, e);
applyFilter('useCase', useCase, e);
}} />
</Layout.Stack>
@@ -23,8 +23,6 @@
let otherEmail = '';
async function sendTestEmail() {
const email = selected === 'self' ? $user.email : otherEmail;
console.log(email);
// TODO: replace with test method
sdk.forProject(page.params.region, page.params.project).messaging.createEmail(
ID.unique(),
@@ -59,9 +59,6 @@
});
async function sendTestMessage() {
const email = selected === 'self' ? $user.email : otherEmail;
console.log(email);
// TODO: replace with test method
sdk.forProject(page.params.region, page.params.project).messaging.createPush(
ID.unique(),
@@ -9,7 +9,6 @@
export let variables: Partial<Models.Variable>[] = [];
function deleteVariable() {
console.log(variables, currentVariable);
variables = variables.filter((v) => v.key !== currentVariable.key);
variables = [...variables];
currentVariable = null;
@@ -60,8 +60,8 @@
undefined
);
invalidate(Dependencies.SITE);
} catch (error) {
console.log(error);
} catch {
return;
}
}
</script>
@@ -125,8 +125,6 @@
};
})
: [];
$: console.log(files);
</script>
<svelte:head>
@@ -175,7 +175,6 @@
`${base}/project-${page.params.region}-${page.params.project}/sites/create-site/deploying?site=${site.$id}&deployment=${deployment.$id}`
);
} catch (e) {
console.log(e);
addNotification({
type: 'error',
message: e.message
@@ -25,11 +25,6 @@
}
});
});
// $: console.log(data.site);
$: console.log(data.deployment);
$: console.log(data.deploymentList);
// $: console.log(data.proxyRuleList);
</script>
<Container>
@@ -26,7 +26,6 @@
if (message.events.includes('sites.*.deployments.*.update')) {
invalidate(Dependencies.DEPLOYMENTS);
invalidate(Dependencies.SITE);
console.log(message);
return;
}
if (message.events.includes('sites.*.deployments.*.delete')) {
@@ -68,8 +68,8 @@
undefined
);
invalidate(Dependencies.SITE);
} catch (error) {
console.log(error);
} catch {
return;
}
}
</script>
@@ -64,9 +64,8 @@
}
return sorted;
} catch (error) {
console.log(installations);
console.log(error);
} catch {
return;
}
}
@@ -126,8 +125,6 @@
error = e.message;
}
}
$: console.log($repository);
</script>
<Modal title="Create Git deployment" bind:show onSubmit={createDeployment} bind:error>
@@ -55,13 +55,14 @@
});
async function fetchUsage() {
metrics = metrics.map((metric) => {
metric.value = null;
return metric;
});
// Add timeout to make it look nicer
setTimeout(async () => {
metrics.forEach((metric) => {
metric.value = null;
});
metrics = metrics;
try {
const usage = await sdk
.forProject(page.params.region, page.params.project)
@@ -84,12 +85,10 @@
}
return metric;
});
metrics = metrics;
console.log(usage);
} catch (error) {
console.log(error);
} catch {
return;
}
}, 800);
}, 500);
}
</script>
@@ -106,8 +106,8 @@
undefined
);
invalidate(Dependencies.SITE);
} catch (error) {
console.log(error);
} catch {
return;
}
}
</script>
@@ -136,8 +136,8 @@
site?.specification || undefined
);
invalidate(Dependencies.SITE);
} catch (error) {
console.log(error);
} catch {
return;
}
}
@@ -9,8 +9,6 @@
// $: totalBuilds = data.buildsTotal;
// $: countBuilds = data.builds;
$: console.log(data);
</script>
<Container>
@@ -6,8 +6,6 @@
export let data;
$: total = data.deploymentsTotal;
$: count = data.deployments;
$: console.log(data);
</script>
<Container>
@@ -69,7 +69,6 @@
async function handleVariableCreated(event: CustomEvent<Models.Variable[]>) {
const variables = event.detail;
console.log(variables);
try {
const promises = variables.map((variable) =>
sdkCreateVariable(variable.key, variable.value, variable?.secret || false)
@@ -115,7 +114,6 @@
}
async function handleVariableSecret(event: CustomEvent<Models.Variable>) {
const variable = event.detail;
console.log(variable);
try {
await sdkUpdateVariable(variable.$id, variable.key, variable.value, variable.secret);
selectedVar = null;
@@ -369,16 +367,16 @@
</Button>
<svelte:fragment slot="tooltip" let:toggle>
<ActionMenu.Root>
<ActionMenu.Item.Button
trailingIcon={IconPencil}
on:click={(e) => {
selectedVar = variable;
showUpdate = true;
toggle(e);
}}>
Update
</ActionMenu.Item.Button>
{#if !variable.secret}
<ActionMenu.Item.Button
trailingIcon={IconPencil}
on:click={(e) => {
selectedVar = variable;
showUpdate = true;
toggle(e);
}}>
Update
</ActionMenu.Item.Button>
<ActionMenu.Item.Button
trailingIcon={IconEyeOff}
on:click={(e) => {
@@ -76,6 +76,7 @@
<Selector.Checkbox
id="secret"
label="Secret"
disabled={selectedVar.secret}
bind:checked={pair.secret}
description="If selected, you and your team won't be able to read the values after creation." />
</Layout.Stack>
@@ -15,8 +15,7 @@
await sdk.forConsole.projects.get(projectId);
const jwt = await sdk.forConsole.account.createJWT();
window.location.href = `${origin}/_appwrite/authorize?jwt=${jwt.jwt}&path=${path}`;
} catch (error) {
console.log(error);
} catch {
goto(
`${base}/auth/preview/access?origin=${origin}&path=${path}&projectId=${projectId}`
);
+1 -4
View File
@@ -4,13 +4,10 @@ import { redirect } from '@sveltejs/kit';
export const load = async ({ parent, url }) => {
const { account } = await parent();
console.log(url);
// const params = new URLSearchParams(window.location.search);
const projectId = url.searchParams.get('projectId');
const origin = url.searchParams.get('origin');
const path = url.searchParams.get('path');
console.log(projectId);
if (!account) {
redirect(
303,
@@ -102,12 +102,6 @@
await register();
}
}
// async function requestAccess() {
// //TODO: Implement request access
// }
$: console.log(data);
</script>
{#if $app.themeInUse === 'dark'}