Switch to China Region (国服)
By default the SDK targets the US region (env unset → 'prod' → https://api.xtool.com). To run against the China region, set env to 'prod_cn' during initialization — that single option is the only required change.
One-line switch
ts
import { GeneratorSDK } from '@atomm-developer/generator-sdk'
const sdk = GeneratorSDK.init({
appKey: 'your_app_key',
env: 'prod_cn', // China region
})US vs China region
US (prod) | China (prod_cn) | |
|---|---|---|
| API BaseURL | https://api.xtool.com | https://api.makeblock.com |
| Default language | en | zh |
| Language mode | Multi-language (URL prefix /de/…) | Single language (locked to zh) |
Language behavior
In the China region, sdk.language.getCurrentLocale() resolves to 'zh' by default (single-language: no URL prefix, no browser detection). See the Language Module for the full resolution priority.
With generator-workbench
If you use generator-workbench, the workbench derives its region from the SDK instance you pass in — sdk.getEnv() is the single source of truth. Creating the SDK with env: 'prod_cn' is all that's required:
ts
const sdk = GeneratorSDK.init({ appKey: 'your_app_key', env: 'prod_cn' })
workbench.sdk = sdk
workbench.config = {
sdk,
atommProEnv: 'prod_cn', // optional; if set, must match the SDK env
// ...other options
}
workbench.mount()- If
config.atommProEnvis omitted, the workbench still uses the SDK env. If it is set but differs from the SDK env, the workbench logs a warning and uses the SDK env as the source of truth. - In the China region the workbench also applies CN defaults automatically: default UI locale
zh, and the credits / user-center links point towww.atomm.com.cninstead ofwww.atomm.com.
Notes
- Separate instance per region. The instance cache key is
{appKey}::{env}, soprodandprod_cnare two independent SDK instances — don't mix them within one app. - US is the default. Omitting
env(or passing'prod') targets the US region; you must explicitly pass'prod_cn'for China. - Login state is restored from the shared-domain
utokencookie the same way in both regions (see SDK Initialization).
See also: SDK Initialization · Language Module · TypeScript Types