A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
feat(server): serve the OpenAI plugin domain verification token
Amruth Pillai40f4595c6a01
diff --git a/.env.example b/.env.exampleindex 7a015e78e..5a48cde8c 100644--- a/.env.example+++ b/.env.example@@ -40,6 +40,11 @@ AUTH_SECRET="change-me-to-a-secure-secret-key-in-production"# Enables the Better Auth Dashboard plugin when set, you probably don't need this.BETTER_AUTH_API_KEY=""+# OpenAI plugin directory domain verification (optional)+# Only needed to publish this instance's MCP server as a ChatGPT/Codex plugin.+# Paste the token from the plugin portal; it is served at /.well-known/openai-apps-challenge.+OPENAI_APPS_CHALLENGE_TOKEN=""+# Social Auth (Google, optional)# Set both values to enable Google sign-in.GOOGLE_CLIENT_ID=""diff --git a/apps/server/src/http/app.ts b/apps/server/src/http/app.tsindex 6afd1e3e1..6795ac589 100644--- a/apps/server/src/http/app.ts+++ b/apps/server/src/http/app.ts@@ -16,6 +16,7 @@ import {handleOAuthAuthorizationServer,handleOAuthProtectedResource,handleOpenIdConfiguration,+ handleOpenAiAppsChallenge,handleWellKnownFallback,} from "../openapi/metadata";import { handleRpc } from "../rpc/handler";@@ -115,6 +116,7 @@ export function createApp(options: AppOptions = {}) {app.get("/.well-known/openid-configuration", (c) => handleOpenIdConfiguration(c.req.raw));app.get("/.well-known/oauth-protected-resource", () => handleOAuthProtectedResource());app.get("/.well-known/oauth-protected-resource/*", () => handleOAuthProtectedResource());+ app.get("/.well-known/openai-apps-challenge", () => handleOpenAiAppsChallenge());app.all("/.well-known/*", () => handleWellKnownFallback());app.on(["GET", "HEAD"], "/robots.txt", (c) => handleRobots({ head: c.req.method === "HEAD" }));diff --git a/apps/server/src/openapi/metadata.ts b/apps/server/src/openapi/metadata.tsindex 8ace7869b..6cfd85178 100644--- a/apps/server/src/openapi/metadata.ts+++ b/apps/server/src/openapi/metadata.ts@@ -7,6 +7,13 @@ import { appVersion } from "../app-version";export const handleOAuthAuthorizationServer = oauthProviderAuthServerMetadata(auth);export const handleOpenIdConfiguration = oauthProviderOpenIdConfigMetadata(auth);+export function handleOpenAiAppsChallenge() {+ if (!env.OPENAI_APPS_CHALLENGE_TOKEN) return new Response("Not Found", { status: 404 });+ return new Response(env.OPENAI_APPS_CHALLENGE_TOKEN, {+ headers: { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "no-store" },+ });+}+export function handleWellKnownFallback() {return new Response("OK", { status: 200 });}diff --git a/docs/self-hosting/environment-variables.mdx b/docs/self-hosting/environment-variables.mdxindex 0e611af8b..b8b12e063 100644--- a/docs/self-hosting/environment-variables.mdx+++ b/docs/self-hosting/environment-variables.mdx@@ -57,10 +57,11 @@ turn on an optional feature.## Sign-in-| Variable | Default | Description |-| -------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |-| `BETTER_AUTH_API_KEY` | unset | Connects the instance to the Better Auth dashboard service. Most instances leave it empty. |-| `BETTER_AUTH_INTERNAL_URL` | `http://127.0.0.1:$PORT` | Address the server uses to reach itself when it verifies OAuth access tokens from API and MCP clients. Set it only if the server cannot reach itself on `127.0.0.1` at `PORT`. |+| Variable | Default | Description |+| ----------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| `BETTER_AUTH_API_KEY` | unset | Connects the instance to the Better Auth dashboard service. Most instances leave it empty. |+| `OPENAI_APPS_CHALLENGE_TOKEN` | unset | Domain verification token from the OpenAI plugin portal, served as plain text at `/.well-known/openai-apps-challenge`. Only needed to publish your instance's MCP server as a ChatGPT or Codex plugin. |+| `BETTER_AUTH_INTERNAL_URL` | `http://127.0.0.1:$PORT` | Address the server uses to reach itself when it verifies OAuth access tokens from API and MCP clients. Set it only if the server cannot reach itself on `127.0.0.1` at `PORT`. |### Social sign-indiff --git a/packages/env/src/server.ts b/packages/env/src/server.tsindex 82e5f3054..ce0f8ca11 100644--- a/packages/env/src/server.ts+++ b/packages/env/src/server.ts@@ -94,6 +94,8 @@ export const env = createEnv({// AuthenticationAUTH_SECRET: z.string().min(1),BETTER_AUTH_API_KEY: z.string().min(1).optional(),+ // Domain verification token from the OpenAI plugin portal, served at /.well-known/openai-apps-challenge.+ OPENAI_APPS_CHALLENGE_TOKEN: z.string().trim().min(1).optional(),// Social Auth (Google)GOOGLE_CLIENT_ID: z.string().min(1).optional(),diff --git a/turbo.json b/turbo.jsonindex 84c57eb08..2826c0ebe 100644--- a/turbo.json+++ b/turbo.json@@ -261,6 +261,7 @@"TRUSTED_PROXIES","BETTER_AUTH_API_KEY","BETTER_AUTH_INTERNAL_URL",+ "OPENAI_APPS_CHALLENGE_TOKEN","GOOGLE_CLIENT_ID","GOOGLE_CLIENT_SECRET","GITHUB_CLIENT_ID",