@bigbinary/neeto-custom-domains-frontend

中文文档
3.5.8发布于 2026/10/30UNLICENSEDTypeScriptESM + CJS近 30 天下载 1.7万

A repo acts as the source of truth for the new nanos structure, configs, data etc.

原始使用文档
文档目录5 节
  1. Contents
  2. Development with Host application
  3. Migrating existing domains to Cloudflare
  4. Instructions for Publishing
  5. Integrations

neeto-custom-domains-nano

The neeto-custom-domains-nano manages custom domains across neeto applications.

Contents

  1. Development with Host application
  2. Instructions for publishing

Development with Host application

The engine provides the backend setup for neetoCustomDomains.

Installation

  1. Add this line to your application's Gemfile:
source "NEETO_GEM_SERVER_URL" do
  # ... existing gems

  gem "neeto-custom-domains-engine"
end
  1. And then execute:
bundle install
  1. Run migrations
rails neeto_custom_domains_engine:install:migrations
rails db:migrate

Usage

  1. Add association
# If custom domain is associated to Organization
class Organization < ApplicationRecord
  include NeetoCustomDomainsEngine::CustomDomainable
end

# If custom domain is associated to other resources (eg: Site)
class Site < ApplicationRecord
  include NeetoCustomDomainsEngine::CustomDomainable
end

The concern adds the custom_domains association, primary_custom_domain and canonical_root_url(fallback). Remove any has_many :custom_domains or primary_custom_domain the model already defines. A model method overrides the concern's, and the concern's version returns only an active domain without a redirection, which canonical URLs and the redirect rely on.

  1. Add controller

All common controller logic is extracted to the engine. However, we still need to load some records from the host app controller.

If the custom domain is associated with Organization, add a Api::V1::CustomDomainable concern in the host app and include it in the controller. This keeps the loader reusable across controllers that need it.

# app/controllers/concerns/api/v1/custom_domainable.rb
module Api::V1::CustomDomainable
  extend ActiveSupport::Concern

  private

    def load_custom_domainable!
      @custom_domainable = organization
    end
end
class Api::V1::Admin::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
  include Api::V1::CustomDomainable
end

If the custom domain is associated with another resource (eg. Site), define load_custom_domainable! directly in the controller instead:

class Api::V1::Admin::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
  private

    def load_custom_domainable!
      @custom_domainable = organization.sites.find(params[:site_id])
    end
end
  1. Add a CustomDomainConcern model concern

The engine's NeetoCustomDomainsEngine::Domain model needs custom_domain_url and organization to be available on the domain record — they are used, for example, when generating links in notification emails and when pushing the domain to NeetoTower.

Define the concern in the host app at the exact path below. The engine auto-includes it via include CustomDomainConcern if defined?(CustomDomainConcern), so no initializer or manual patching is needed — Rails autoloading handles it.

The path returned by custom_domain_url is product-specific. Point it at wherever the custom domain settings page is mounted in your product's admin panel (the example below uses NeetoQuiz's path; replace it for your product).

# app/models/concerns/custom_domain_concern.rb
module CustomDomainConcern
  extend ActiveSupport::Concern

  def custom_domain_url
    root_url = organization.root_url
    # Replace this path with the route to the custom domain settings page
    # in your product's admin panel.
    "#{root_url}/admin/admin-panel/custom-domain"
  end

  def organization
    custom_domainable
  end
end

If the custom_domainable is not the Organization itself (eg. Site), update organization to traverse to the owning organization (eg. custom_domainable.organization).

  1. Include the following module to your application's config/routes.rb file:
include NeetoCustomDomainsEngine::Routes::Draw

  1. Define required routes.
# config/routes.rb
custom_domains_routes :acme

# routes/api.rb within the admin routes
custom_domains_routes :domain
  1. Add frontend component. url should be the api to the custom domains controller.
import { CustomDomain as NeetoCustomDomainDashboard } from "@bigbinary/neeto-custom-domains-frontend";
import { BASE_API_V1_URL, SINGULAR } from "neetocommons/constants";
import HelpPopover from "neetomolecules/HelpPopover";
import { useTranslation } from "react-i18next";

import routes from "routes";
import { EVENTS } from "src/constants";
import { CUSTOM_DOMAIN_HELP_DOC_URL } from "src/constants/urls";

const CustomDomain = () => {
  const { t } = useTranslation();

  const breadcrumbs = [
    { link: routes.admin.settings.index, text: t("titles.settings") },
    {
      link: routes.admin.settings.customDomain,
      text: t("neetoCustomDomains.customDomain", SINGULAR),
    },
  ];

  const CUSTOM_DOMAIN_DNS_PROVIDER_HELP_DOCS = {
  cloudflare: {
    subdomain: `${PERMANENT_URL}/permanent-url-1`,
    rootDomain: `${PERMANENT_URL}/permanent-url-2`,
  },
  unknown: {
    subdomain: `${PERMANENT_URL}/permanent-url-3`,
    rootDomain: `${PERMANENT_URL}/permanent-url-4`,
  },
  namecheap: {
    subdomain: `${PERMANENT_URL}/permanent-url-5`,
    rootDomain: `${PERMANENT_URL}/permanent-url-6`,
  },
  hostinger: {
    subdomain: `${PERMANENT_URL}/permanent-url-7`,
    rootDomain: `${PERMANENT_URL}/permanent-url-8`,
  },
  digitalocean: {
    subdomain: `${PERMANENT_URL}/permanent-url-9`,
    rootDomain: `${PERMANENT_URL}/permanent-url-10`,
  },
  godaddy: {
    subdomain: `${PERMANENT_URL}/permanent-url-11`,
    rootDomain: `${PERMANENT_URL}/permanent-url-12`,
  },
  squarespace: {
    subdomain: `${PERMANENT_URL}/permanent-url-13`,
    rootDomain: `${PERMANENT_URL}/permanent-url-14`,
  },
  wix: {
    subdomain: `${PERMANENT_URL}/permanent-url-15`,
    rootDomain: `${PERMANENT_URL}/permanent-url-16`,
  },
  porkbun: {
    subdomain: `${PERMANENT_URL}/permanent-url-17`,
    rootDomain: `${PERMANENT_URL}/permanent-url-18`,
  },
  networksolutions: {
    subdomain: `${PERMANENT_URL}/permanent-url-19`,
    rootDomain: `${PERMANENT_URL}/permanent-url-20`,
  },
  aws: {
    subdomain: `${PERMANENT_URL}/permanent-url-21`,
    rootDomain: `${PERMANENT_URL}/permanent-url-22`,
  },
  strato: {
    subdomain: `${PERMANENT_URL}/permanent-url-23`,
    rootDomain: `${PERMANENT_URL}/permanent-url-24`,
  },
}

  return (
    <div className="w-full">
      <NeetoCustomDomainDashboard
        appName="appname" // Eg: `cal`, `form`
        dnsHelpDocs={CUSTOM_DOMAIN_DNS_PROVIDER_HELP_DOCS}
        helpDocUrl={CUSTOM_DOMAIN_HELP_DOC_URL}
        subdomainPlaceholder="subdomain-placeholder" // Eg: `schedule` for NeetoCal and `form` for NeetoForm
        url={`${BASE_URL}/custom-domains`}
        { ...{ breadcrumbs } }
      />
    </div>
  );
};

export default CustomDomain;
  1. Mount the CustomDomain component at the desired path.
SEO: redirect to the custom domain and canonical URLs

Once a custom domain is active, public pages on the product subdomain should redirect to it, and canonical URLs should point to it.

  1. Include NeetoCustomDomainsEngine::CanonicalHostRedirection in the public base controller only. Never include it in admin, API or auth controllers. Those must keep working on the subdomain, so a customer whose domain broke can still log in and fix it.
  2. The concern reads the domainable from @organization. If the domainable is something else (eg: a Site), override the private method canonical_custom_domainable.
  3. Use canonical_url for <link rel="canonical"> and og:url. It keeps ?page=N for pages beyond the first and drops every other query param.
  4. Build sitemap and robots URLs from canonical_root_url(fallback), where the fallback is the subdomain base URL.

GET and HEAD requests on the subdomain get a 301 to the same path and query on the primary custom domain. The redirect only happens while the domain is active and has no redirection of its own. Otherwise the subdomain serves the page and canonical URLs fall back to the subdomain. These requests are never redirected: JSON requests, browser loads that are not a top-level page navigation (a Sec-Fetch-Dest other than document, such as iframes, fetch and XHR calls or images), signed-in users (so private content and draft previews keep working on the subdomain), and requests on any other custom domain of the same domainable. The 301 is cached privately for one hour.

Each redirect arms a liveness probe for domains with a stored certificate. If the redirected request does not arrive on the custom domain within a minute, the engine runs ReconcileCertificateJob for that domain. A domain that cannot be reached for over an hour is marked failed and the owner gets an email. A hit on the custom domain, or a probe, is trusted for six to seven hours, so each domain is probed at most once in that window.

ENV variables

For the working of this engine we need the following env variables.

LETS_ENCRYPT_PRIVATE_KEY: < For requesting SSL certificates >
LETS_ENCRYPT_DIRECTORY_URL: < For requesting SSL certificates >
LETS_ENCRYPT_APP_NAME: < For pushing SSL certificate and custom domains >
NEETO_DEPLOY_APP: < To identify in which platform the app is deployed NeetoDEploy/Heroku>
NEETO_DEPLOY_AUTH_TOKEN: <For pushing SSL certificate and custom domains>

Optional, staging only:

CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX: < e.g. review.neetoautomation.com >

Hostnames one label under this suffix are activated without a DNS check or a certificate, because Cloudflare's wildcard certificate already serves them. It is read only when Rails.env.staging?, so setting it anywhere else has no effect.

Migrating existing domains to Cloudflare

Domains created before Cloudflare-for-SaaS was enabled have no route to registration — CloudflareValidationSyncJob is only enqueued when a domain is created, or when a DCV token is fetched. The backfill task is that route. Run it inside each product, one product at a time.

# Changes nothing. Shows what would be registered.
bundle exec rake neeto_custom_domains_engine:cloudflare:backfill_report

# Registers them.
bundle exec rake neeto_custom_domains_engine:cloudflare:backfill

It refuses to run unless NEETO_CUSTOM_DOMAINS_CERTIFICATE_BACKEND is dual or cloudflare and both CLOUDFLARE_SAAS_ZONE_ID and CLOUDFLARE_SAAS_API_TOKEN are set.

variabledefaultwhat it does
MAX_IN_FLIGHT100how many certificates may be validating at once
LIMITnonestop after releasing this many in one run
MAX_MINUTES120wall-clock budget before the run stops

MAX_IN_FLIGHT is the one that matters. Registering costs a single API call per domain, but every domain waiting on validation polls Cloudflare roughly ten times per five minutes. Against a limit near 1,200 requests per five minutes that puts the ceiling around 120 certificates in flight, and the default leaves headroom. Raising it risks rate-limiting every product at once, because the limit is per account rather than per zone.

The task is safe to stop and re-run: a domain that already holds a cloudflare_hostname_id is skipped. Only active domains are registered — a failed domain has DNS that does not point at us, so registering it just churns against the CA. Domains still pending are picked up by a later run once they go active.

Only one backfill may run at a time; a second is refused via a Redis lock.

Registration is not a cutover. It leaves Let's Encrypt serving and Cloudflare idle alongside it. Traffic only moves when the domain's DNS starts pointing at a proxied hostname.

Instructions for Publishing

Consult the building and releasing packages guide for details on how to publish.

Integrations

  • NeetoCal
  • NeetoForm
  • NeetoKb
  • NeetoEngage
  • NeetoSite
  • NeetoRecord
  • NeetoPublish
  • NeetoCourse
  • NeetoCode
  • NeetoDesk
  • NeetoQuiz
  • NeetoPlanner
  • NeetoInvoice
  • NeetoChat
  • NeetoRunner

版本与发布记录

@bigbinary/neeto-custom-domains-frontend 共发布 66 个版本,首次发布于 2024/09/24;过去 12 个月发布了 31 个版本。

版本发布日期距今
3.5.8latest2026/10/309 天前
3.5.72026/10/1127 天前
3.5.62026/10/0930 天前
3.5.52026/10/021 个月前
3.5.42026/10/011 个月前
3.5.32026/09/281 个月前

其他发布通道:beta → 2.1.0-beta3。

关于 @bigbinary/neeto-custom-domains-frontend 的常见问题

@bigbinary/neeto-custom-domains-frontend 是什么?

A repo acts as the source of truth for the new nanos structure, configs, data etc.

如何安装 @bigbinary/neeto-custom-domains-frontend?

在项目目录运行 npm install @bigbinary/neeto-custom-domains-frontend,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:qs(6.16.2)、url(0.11.4)、yup(0.32.11)、antd(5.22.1)、util(^0.12.5)、axios(1.20.0)、ramda(0.29.0)、react(18.3.1)、buffer(^6.0.3)、formik(2.4.6)、i18next(22.5.1)、zustand(4.4.2)、dompurify(3.4.17)、js-logger(1.6.1)、react-dom(18.3.1)、classnames(2.5.1)、stream-http(3.2.0)、tailwindcss(3.4.14)、react-helmet(^6.1.0)、os-browserify(0.3.0)、react-i18next(12.3.1)、vm-browserify(1.1.2)、@babel/runtime(7.29.7)、react-toastify(8.0.2)、tty-browserify(0.0.1)、path-browserify(^1.0.1)、https-browserify(1.0.0)、mixpanel-browser(^2.45.0)、react-router-dom(5.3.3)、crypto-browserify(3.12.1)、source-map-loader(4.0.1)、stream-browserify(^3.0.0)、@bigbinary/neetoui(8.8.3)、@honeybadger-io/js(6.10.1)、@bigbinary/neeto-cist(1.0.17)、@honeybadger-io/react(6.1.25)、@tanstack/react-query(5.59.20)、@bigbinary/neeto-atoms(1.1.2)、@bigbinary/neeto-icons(1.20.89)、@bigbinary/neeto-molecules(5.9.10)、@tanstack/react-query-devtools(5.59.20)、@bigbinary/neeto-commons-frontend(4.14.5)、@bigbinary/neeto-filters-frontend(4.5.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bigbinary/neeto-custom-domains-frontend 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bigbinary/neeto-custom-domains-frontend 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bigbinary/neeto-custom-domains-frontend 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bigbinary/neeto-custom-domains-frontend 可以商用吗?

@bigbinary/neeto-custom-domains-frontend 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@bigbinary/neeto-custom-domains-frontend 的下载量有多少?

根据 npm 官方下载统计,@bigbinary/neeto-custom-domains-frontend 在 2026/10/08 – 2026/11/06 这 30 天内被下载 16,777 次,日均约 559 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bigbinary/neeto-custom-domains-frontend 还在维护吗?

最新版本 3.5.8 发布于 2026/10/30(9 天前);至今共发布 66 个版本,其中过去 12 个月发布了 31 个;首次发布于 2024/09/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。