Skip to content

Commit fbc5da4

Browse files
committed
feat: add forever cache control header
1 parent 2e32d89 commit fbc5da4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Options:
99
Example:
1010
(original female) <a href="/?text=こんにちは&lang=ja">/?text=こんにちは&lang=ja</a>
1111
(male pitch) <a href="/?text=こんにちは&lang=ja&pitch=0.8">/?text=こんにちは&lang=ja&pitch=0.8</a>
12-
Repostory:
13-
<a href="https://github.com/sglkc/tts-api">https://github.com/sglkc/tts-api</a>
12+
(json) { "text": "Selamat dunia", "lang": "id" }
13+
Repository:
14+
Please leave a star <a href="https://github.com/sglkc/tts-api">https://github.com/sglkc/tts-api</a> ;)
1415
</pre>

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import * as TTS from '@sefinek/google-tts-api'
99

1010
export default async function main(payload, ffmpegPath = null) {
1111
const { text, lang = 'en', speed, pitch = 1 } = payload
12-
const cors = {
12+
const headers = {
1313
'Access-Control-Allow-Origin': '*',
1414
'Access-Control-Allow-Headers': '*',
1515
'Access-Control-Allow-Methods': '*',
16+
'Cache-Control': 'public, max-age=31536000, immutable'
1617
}
1718

1819
if (!text || !text.length) {
@@ -21,7 +22,7 @@ export default async function main(payload, ffmpegPath = null) {
2122
statusText: '`text` is missing',
2223
headers: {
2324
'content-type': 'text/html; charset=utf-8',
24-
...cors
25+
...headers
2526
}
2627
})
2728
}
@@ -61,6 +62,6 @@ export default async function main(payload, ffmpegPath = null) {
6162
headers: {
6263
'content-type': 'audio/mp3',
6364
'content-disposition': 'inline',
64-
...cors
65+
...headers
6566
}
6667
})}

0 commit comments

Comments
 (0)