Kay
Kay2mo ago

deny path of website instead of whole website

Is it possible to for example deny only a path of a website instead of the whole website?
1 Reply
Deno AI Helper
Deno AI Helper2mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your question, if you're looking to deny access to a specific path on a website that you're serving with Deno, you might be able to achieve this by setting up a route handler that checks the request URL and denies access to the specific path you want to restrict. For example, if you're using the oak middleware framework, you could do something like this:
router.get('/restricted-path', (context) => {
context.response.status = 403;
context.response.body = "Access denied";
});
router.get('/restricted-path', (context) => {
context.response.status = 403;
context.response.body = "Access denied";
});
This would deny access to the path /restricted-path by returning a 403 Forbidden status code. You would, of course, include this in your routing setup where you handle other paths as well. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice, especially in the context of the specific framework or setup you are using.