Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
fix: try and fix middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
uhidontkno committed May 18, 2024
1 parent 6a2f914 commit 3d5601a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,24 @@ server.onError(({ code, error, set }) => {
}
});*/

function trollLinkLeakers(req:Request, res:any, next:any) {
res.setHeader("Referrer-Policy", "unsafe-url");
const referer = req.headers.origin || req.headers.referer;

if (!req.url.startsWith("/j/") && referer && (referer.startsWith('https://links.surfskip.com') ||referer.startsWith('https://docs.google.com') || referer.startsWith('https://sites.google.com'))) {
return res.redirect('/j/index.html');
}
res.setHeader("Referrer-Policy", "unsafe-url");
next(); // Continue to the next middleware if referer doesn't match
}
server.use(trollLinkLeakers)

// Run the startup "job"
require("./modules/startupjob.ts");
server.use("/", express.static("static/"));
server.use(cors()); // Express cors plugin
server.use(rateLimit(config.ratelimit));

function trollLinkLeakers(req:Request, res:any, next:any) {
const referer = req.headers.referer;
if (!req.url.startsWith("/j/") && referer && (referer.startsWith('https://docs.google.com') || referer.startsWith('https://sites.google.com'))) {
return res.redirect('/j/index.html');
}
next(); // Continue to the next middleware if referer doesn't match
}
server.use("/*",trollLinkLeakers)

if (process.argv.includes("--unavailable") || process.argv.includes("-u")) {
require("./modules/unavailable.ts");
Expand Down
2 changes: 1 addition & 1 deletion tempcaptcha.db
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{"fb031aa4-bb65-446d-8461-40324bb5f741":"4Oo.0","16e25110-9922-4946-9f88-aeb2c7356656":"40O..10"}

0 comments on commit 3d5601a

Please sign in to comment.