You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将部署于已停止支持的Cedar-14栈的旧Heroku应用流量转发至Heroku-18栈的新版本应用?

Absolutely, there are practical ways to route traffic from your old Cedar-14 app to the new Heroku-18 app—even with their default Heroku domains. Here are the most reliable approaches, tailored to your situation where you can't rebuild the old app:

1. Use a Heroku Redirect Add-On (No Code Changes Required)

Since you can't update or rebuild the old app, a Heroku redirect add-on is the cleanest solution. These tools handle redirects at the server level, no code modifications needed:

  • Install the free basic Redirector add-on to your old app:
    heroku addons:create redirector:basic -a your-old-app-name
    
  • Configure it to permanently redirect all traffic to your new app's domain. You can do this via the Heroku Dashboard (navigate to your old app → Resources → Redirector → Settings) or the CLI:
    heroku config:set REDIRECTOR_TARGET=https://new-app-name.herokuapp.com REDIRECTOR_TYPE=permanent -a your-old-app-name
    
  • Restart your old app's dynos to apply the changes:
    heroku restart -a your-old-app-name
    

This will send every request to your old app's default domain straight to the new app, with a 301 permanent redirect (ideal for preserving SEO and guiding users to the correct place automatically).

2. Leverage Environment Variables (If Your App Already Supports Redirects)

If your old app has existing logic that checks for a redirect environment variable (some frameworks or apps include this out of the box), you can set a config var to trigger the redirect without rebuilding:

Run this command to set the target URL:

heroku config:set PERMANENT_REDIRECT_URL=https://new-app-name.herokuapp.com -a your-old-app-name

If your app is set to redirect when this variable exists, it will start sending traffic to the new app immediately after a dyno restart. Note: This only works if your app already has this redirect logic in place—since you can't rebuild, you can't add new code to support it.

3. Pipeline Traffic Routing (Long-Term Custom Domain Solution)

While this doesn't directly forward traffic from the old default domain, if you're open to using a custom domain as a central entry point:

  • Add a custom domain to your new Heroku-18 app
  • Move both apps into the same Heroku Pipeline, setting the new app as the production stage
  • Configure the pipeline to route 100% of traffic from the custom domain to the production app
  • Encourage users to switch to the custom domain (you can still use the redirect add-on on the old app to send its default domain traffic to the custom domain)

Important Note

Cedar-14 has been end-of-life since 2020, so Heroku may eventually retire the old app entirely. These methods are temporary fixes—make sure to migrate users to the new app's domain as soon as possible to avoid disruption.

内容的提问来源于stack exchange,提问作者BenU

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 11:22:47