Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there any way to disable/off inspect on my server or website? (NextJS)

I’m attempting to deactivate inspect on my server or website so that others can’t view my code and other reasons; I’m sorry if this seems too insecure, but if there’s a method, please tell/show me… I’ve been researching and have discovered some solutions, but I’ve tried and failed. Here is the code for what I attempted.

_document.js:

<Html onContextMenu={false}>
 <Head>
 {...}
 </Head>
 <body onContextMenu="false">
 {...}
  <Script>
   {`document.addEventListener('keydown', function() {
     if (event.keyCode == 123) {
       alert("You Can not Do This!");
       return false;
     } else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
       alert("You Can not Do This!");
        event.preventDefault();
       return false;
     } else if (event.ctrlKey && event.keyCode == 85) {
       alert("You Can not Do This!");
       return false;
     }
   }, false);
  
   if (document.addEventListener) {
     document.addEventListener('contextmenu', function(e) {
       alert("You Can not Do This!");
       e.preventDefault();
     }, false);
   } else {
     document.attachEvent('oncontextmenu', function() {
       alert("You Can not Do This!");
       window.event.returnValue = false;
     });
   }
 `}
 </Script>
</body>
</Html>

All of the necessary imports are also present… I appreciate your assistance!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No, there’s no way to do that.

There might be some workarounds like blocking right click for example, but in general, source code of the webpage/website isn’t something you can protect against copying/stealing because that’s how Web works.
Whoever wants to see your source code might simply get it even without browser, if needed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading