Skip to content

Commit c07a839

Browse files
committed
Fix cors
1 parent a987987 commit c07a839

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.github/workflows/servers.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
if: github.ref == 'refs/heads/develop'
5151
run: |
5252
ssh ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }} << 'EOF'
53+
export REMOTE_URLS=${{ secrets.REMOTE_URLS }}
5354
pm2 stop setonix-servers || true
5455
cd /var/www/servers.setonix
5556
PORT=${{ secrets.SERVERS_PORT }} pm2 start dist/server/entry.mjs --name setonix-servers --update-env

servers/src/pages/data.json.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
import type { APIRoute } from 'astro';
2-
import { loadServersFromConfig } from '../scripts/servers/list';
1+
import type { APIRoute } from "astro";
2+
import { loadServersFromConfig } from "../scripts/servers/list";
33

44
export async function GET() {
55
const servers = await loadServersFromConfig();
6-
return new Response(JSON.stringify({servers}), {
6+
return new Response(JSON.stringify({ servers }), {
77
status: 200,
8-
headers: { 'Content-Type': 'application/json' },
8+
headers: {
9+
"Content-Type": "application/json",
10+
"Access-Control-Allow-Origin": "*",
11+
},
912
});
10-
};
13+
}
14+
15+
export const OPTIONS: APIRoute = async () => {
16+
return new Response(null, {
17+
headers: {
18+
"Access-Control-Allow-Origin": "*",
19+
"Access-Control-Allow-Methods": "GET",
20+
"Access-Control-Allow-Headers": "Content-Type",
21+
"Access-Control-Max-Age": "21600", // 6 h cache
22+
},
23+
});
24+
};

0 commit comments

Comments
 (0)