Skip to content

Commit 236ff0b

Browse files
committed
hot standby
1 parent 30f1674 commit 236ff0b

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

astro.config.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// @ts-check
2-
import { defineConfig } from 'astro/config';
2+
import { defineConfig } from 'astro/config'
33

4-
import vercel from '@astrojs/vercel/serverless';
4+
import vercel from '@astrojs/vercel/serverless'
55

66
// https://astro.build/config
77
export default defineConfig({
8-
output: 'server',
9-
adapter: vercel(),
10-
});
8+
output: 'server',
9+
adapter: vercel({ maxDuration: 300 }),
10+
})

src/pages/api/generate.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ const serverOptions = {
2525
}
2626

2727
export const GET: APIRoute = async ({ url }) => {
28-
const { isDev, height, width } = {
28+
const { isDev, height, width, cacheControl } = {
2929
isDev: url.searchParams.get('dev') === 'true',
3030
height: url.searchParams.get('h'),
3131
width: url.searchParams.get('w'),
32+
cacheControl: url.searchParams.get('cache-control'),
3233
}
3334
const options = isDev ? Localoptions : serverOptions
3435

@@ -73,7 +74,7 @@ export const GET: APIRoute = async ({ url }) => {
7374
headers: {
7475
'Content-Type': 'image/png',
7576
'access-control-allow-origin': '*',
76-
'cache-control': `public, max-age=31536000`,
77+
'cache-control': cacheControl ?? `public, max-age=31536000`,
7778
},
7879
})
7980
} catch (error) {

vercel.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"crons": [
3+
{
4+
"path": "/api/generate?cache-control=no-cache&src=https://example.com/",
5+
"schedule": "*/5 * * * *"
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)