Edits history of script submission #12069 for ' Update production instance domain (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * Update production instance domain
     * Change the domain of a production instance.
     */
    export async function main(
      auth: Clerk,
      body: { home_url?: string; is_secondary?: false | true },
    ) {
      const url = new URL(`https://api.clerk.com/v1/instance/change_domain`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago