首页 > 解决方案 > 用于多租户应用程序(子域)的 ngrok + stripe webhook

问题描述

我目前正在测试一个多租户应用程序。当用户注册帐户时,会为该帐户创建一个子域。成功创建后,会发生以下过​​程:

帐户控制器

def create
    @account = Account.new(account_params)
    if @account.save
      sign_in(@account.owner)
      flash[:notice] = "Your account has been created."
      redirect_to root_url(subdomain: @account.subdomain)
    else
      flash.now[:alert] = "Sorry, your account could not be created."
      render :new
    end
  end

用户被重定向到他们的帐户,网址现在是 subdomain.url.com

以上内容在开发中与 lvh.me 配合得很好,但是当我使用 ngrok 进行测试时 - 用于测试条带网络书 - 我的 ngrok 隧道地址与正在设置的子域冲突。

我的条纹电子书看起来像这样: https ://3abg89zc.ngrok.io/webhooks/stripe

创建帐户后,我的网址将转到:https ://subdomain.ngrok.io/

标签: ruby-on-railsdevisestripe-paymentsmulti-tenant

解决方案


我相信这里的答案可能有效: 如何通过 ngrok 访问子域?

但是,我发现使用 heroku 在实时环境中进行测试更容易。


推荐阅读