Skip to content

Disable Inspect Plugin

File Information

  • Path: plugins/disable-inspect.js
  • Purpose: Disables browser developer tools in production

Overview

The Disable Inspect plugin prevents users from accessing browser developer tools in production environments. It disables the right-click context menu and can optionally disable keyboard shortcuts for developer tools. This provides basic protection against casual inspection of the application.

Key Features

  1. Context Menu Disable

    • Prevents right-click menu
    • Production only
    • Client-side only
  2. Optional Keyboard Shortcuts

    • F12 disable (commented)
    • Ctrl+Shift+I disable (commented)
    • Ctrl+U disable (commented)

Configuration

The plugin only runs when:

  • process.client - Browser environment
  • process.env.APP_ENV === 'production' - Production mode

Usage

The plugin runs automatically in production:

  • No configuration needed
  • Automatically disables context menu
  • Keyboard shortcuts disabled (if uncommented)

Security Note

Important: This plugin provides only basic protection:

  • Determined users can still access dev tools
  • Not a security measure
  • Mainly prevents casual inspection
  • Can be bypassed

Code Structure

javascript
// Disables right-click context menu
document.addEventListener('contextmenu', (event) => {
  event.preventDefault()
})

// Optional: Disable keyboard shortcuts (commented)
// F12, Ctrl+Shift+I, Ctrl+U

When to Use

  • Production environments
  • When you want to discourage inspection
  • Basic content protection
  • Not for security-critical applications

Notes for Development

  • Plugin only runs in production
  • Client-side only
  • Basic protection only
  • Can be bypassed
  • Not a security feature