Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions go_live.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +49 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
if (canonical_host = ENV["CANONICAL_HOST"]).present?
match "*path", constraints: ->(req) { req.host != canonical_host && !req.path.start_with?("/.well-known/") },
to: redirect { |_params, req| "https://#{canonical_host}#{req.fullpath}" }, via: :all
end

I'd rather use a separate ENV variable here. APP_HOST is in most cases also set in staging apps AFAIK

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that what we want? If the env is set in staging/develop, then the deplo.io host redirects to renuoapp.

end
```

## Heroku

* Check the size and amount of dynos on Heroku
Expand Down