rails localhost https

Step 1: Generate a self-signed SSL certificate Run the following command in the terminal to generate a self-signed SSL certificate: openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt

Step 2: Configure Rails to use SSL in development environment Open the config/environments/development.rb file and add the following configuration: config.force_ssl = true

Step 3: Configure Puma to use SSL In the config/puma.rb file, add the SSL configuration to enable HTTPS: bind 'ssl://127.0.0.1:3000?key=localhost.key&cert=localhost.crt'

Step 4: Start Rails server with SSL Start the Rails server with SSL using the following command: rails s -b 'ssl://127.0.0.1:3000?key=localhost.key&cert=localhost.crt'

Step 5: Access the application via HTTPS Open a web browser and navigate to https://localhost:3000 to access the Rails application using HTTPS.