diff --git a/go_live.md b/go_live.md index 182eb33a..9b7bde26 100644 --- a/go_live.md +++ b/go_live.md @@ -37,6 +37,22 @@ When preparing your app for production on Deploio, ensure the following: For detailed instructions and best practices, including quick start guides for a variety of frameworks, please refer to the [Deploio deployment documentation](https://guides.deplo.io/user-guide/network-and-deployment.html#network-deployment). +### URL rewriting in Rails + +Ensure that all custom hostnames are configured on Deploio. For example, if the app host +is `example.com`, configure `example.com`, `www.example.com`, and `example-main.renuoapp.ch`. + +Then, redirect everything to the main hostname by adding the following to your `config/routes.rb` file: + +```rb +Rails.application.routes.draw do + if (app_host = ENV["APP_HOST"]).present? + match "*path", constraints: ->(req) { req.host != app_host && !req.path.start_with?("/.well-known/") }, + to: redirect { |_params, req| "https://#{app_host}#{req.fullpath}" }, via: :all + end +end +``` + ## Heroku * Check the size and amount of dynos on Heroku