Skip to content

Commit c2084c1

Browse files
Enable CORS
1 parent e0983d6 commit c2084c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/server.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ const filter = (contests, options) => {
3333
};
3434

3535
const server = http.createServer((req, res) => {
36+
// Set CORS headers
37+
res.setHeader('Access-Control-Allow-Origin', '*');
38+
res.setHeader('Access-Control-Request-Method', '*');
39+
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
40+
res.setHeader('Access-Control-Allow-Headers', '*');
41+
if (req.method === 'OPTIONS') {
42+
res.writeHead(200);
43+
res.end();
44+
return;
45+
}
46+
3647
const { pathname, query } = url.parse(req.url, true);
3748

3849
if (pathname !== '/') {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy