mirror of
https://github.com/jakejarvis/simpip.git
synced 2025-06-27 13:55:42 -04:00
Return 404 on everything except root domain
This commit is contained in:
45
index.js
45
index.js
@ -3,21 +3,32 @@ addEventListener('fetch', event => {
|
||||
})
|
||||
|
||||
async function handle(request) {
|
||||
return new Response(request.headers.get("cf-connecting-ip") + "\n", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: {
|
||||
"Content-Type": "text/plain",
|
||||
"Content-Security-Policy": "default-src 'none';",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"X-Frame-Options": "SAMEORIGIN",
|
||||
"Referrer-Policy": "no-referrer",
|
||||
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
|
||||
"Pragma": "no-cache",
|
||||
"Expires": "Wed, 11 Jan 1984 05:00:00 GMT",
|
||||
"X-Did-You-Know": "You can use \"curl -4 simpip.com\" or \"curl -6 simpip.com\" to get either address!",
|
||||
"X-Source-Code": "https://github.com/jakejarvis/simpip"
|
||||
}
|
||||
});
|
||||
const url = new URL(request.url);
|
||||
let customHeaders = {
|
||||
"Content-Type": "text/plain",
|
||||
"Content-Security-Policy": "default-src 'none';",
|
||||
"Feature-Policy": "accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; sync-xhr 'none'; payment 'none'; usb 'none'; vr 'none'",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"X-XSS-Protection": "1; mode=block",
|
||||
"X-Frame-Options": "SAMEORIGIN",
|
||||
"Referrer-Policy": "no-referrer",
|
||||
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
|
||||
"Pragma": "no-cache",
|
||||
"Expires": "Thu, 01 Jan 1970 00:00:01 GMT",
|
||||
"X-Did-You-Know": "You can use \"curl -4 simpip.com\" or \"curl -6 simpip.com\" to get either address!",
|
||||
"X-Source-Code": "https://github.com/jakejarvis/simpip"
|
||||
}
|
||||
if (url.pathname === '/') {
|
||||
return new Response(request.headers.get("cf-connecting-ip") + "\n", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: customHeaders
|
||||
})
|
||||
} else {
|
||||
return new Response("404 Not Found\n", {
|
||||
status: 404,
|
||||
statusText: "Not Found",
|
||||
headers: customHeaders
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user