Update index.mjs
This commit is contained in:
parent
60c9e91135
commit
1c9b69e15b
1 changed files with 5 additions and 2 deletions
|
@ -67,8 +67,11 @@ async function main(port) {
|
||||||
const hostname = '127.0.0.1';
|
const hostname = '127.0.0.1';
|
||||||
|
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
|
res.setHeader('Access-Control-Allow-Origin', '*'); // Adjust as needed
|
||||||
|
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||||
|
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
||||||
res.statusCode = 200;
|
res.statusCode = 200;
|
||||||
|
|
||||||
// Create URL object and parse query parameters
|
// Create URL object and parse query parameters
|
||||||
const urlObj = new URL(req.url, `http://${req.headers.host}`);
|
const urlObj = new URL(req.url, `http://${req.headers.host}`);
|
||||||
const queryParams = urlObj.searchParams;
|
const queryParams = urlObj.searchParams;
|
||||||
|
@ -92,4 +95,4 @@ async function main(port) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
main(8543)
|
main(8543)
|
||||||
|
|
Loading…
Reference in a new issue