Is there any way to get Heroku error / service message directly without iframe

Heroku allows you to enable a “maintenance mode” for your applications, and also allows you to specify a custom URL that will be served during this period. I just tried this and found that Heroku is serving the user url in the iframe. This was not quite what I expected.

We are using Heroku to host the API service and planned that the custom error / service pages will serve json data. We hope there is a way to directly serve the service URL.

After searching for SO, Quora, and general "Internet" I did not see any posts asking this question, so here I publish SO.

The following are messages related to my question, but do not contact directly.

Old posts before any setup: https://groups.google.com/forum/?fromgroups=#!topic/heroku/EJRtW1XrlpU

Message requesting custom javascript in iframe html rendering: https://groups.google.com/forum/?fromgroups=#!topic/heroku/Db0JEWmuz_w

+5
source share
2 answers

It is not possible to set up error pages (s) other than those indicated here that use iFrame: https://devcenter.heroku.com/articles/error-pages#customize-pages

+1
source

Heroku, ( - ) , , MAINTENANCE. , JSON.

, Rack app call. ( Sinatra . Ruby on Rails app .)

if ENV['MAINTENANCE']
  status = '503'
  headers = {'Content-Type' => 'application/json'}
  body = ['{"message":"The server is undergoing maintenance. Please try again later."}']
  return [status, headers, body]
end

, " , " MAINTENANCE , .

heroku config:set MAINTENANCE=1

" ", MAINTENANCE.

heroku config:unset MAINTENANCE

Voila! JSON REST API.

0

All Articles