get-convex / get-convex/static-hosting
Preview deployment not working with Convex preview deploy key
- Dominant language
- TypeScript
- Stars
- 33
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Hi, first of all really apologize, I had Codex pre-fill this issue, but I really had it try to figure out how to do preview deployments with the static hosting component. I asked it multiple times and it said it was confident it configured everything correctly. We were also fully able to do production deployments successfully.
## Summary
`@convex-dev/static-hosting deploy` cannot complete when `CONVEX_DEPLOY_KEY` is a project-level preview deploy key. Convex successfully creates and deploys the preview backend, including the `staticHosting` component, but the subsequent asset-upload phase cannot resolve that component.
Production deployment of the same commit and configuration succeeds.
## Versions
- `@convex-dev/static-hosting`: 0.2.1
- `convex`: 1.44.0
- Node.js: 22
- pnpm: 11.22.0
- Environment: GitHub Actions on Ubuntu
## Configuration
`convex/convex.config.ts`:
```ts
import { defineApp } from "convex/server";
import staticHosting from "@convex-dev/static-hosting/convex.config";
const app = defineApp();
app.use(staticHosting);
export default app;
```
The GitHub Actions job receives a valid project preview deploy key through `CONVEX_DEPLOY_KEY`.
## Reproduction
Run:
```sh
npx @convex-dev/static-hosting deploy
```
The command successfully claims a named preview deployment and reports:
```text
[Preview] ::preview/
Installed component staticHosting.
Deployed Convex functions to https://.convex.cloud
```
It then fails during component discovery/upload:
```text
Could not reach component "staticHosting" or "selfHosting".
Deploy the Convex backend first (npx convex deploy) and ensure --component matches the name in convex.config.ts.
```
Splitting the operation produces the same result:
```sh
npx convex deploy
npx static-hosting upload --build
```
The first command deploys the preview backend successfully. The second cannot address the newly claimed preview deployment using the project-level preview key.
## Expected behavior
The standard static-hosting deploy command should build, deploy, and upload assets to the preview deployment selected or created by a Convex preview deploy key, just as it does with a production-scoped deploy key.
## Additional verification
- The preview key is accepted by `convex deploy` and creates/reuses the expected preview deployment.
- The dashboard shows the preview backend and deployed component.
- The identical static-hosting configuration deploys successfully with a production-scoped key.
- Explicitly using the default component name does not change the result.
- No existing issue or pull request in this repository appeared to cover preview deploy keys.
## Troubleshooting performed
To rule out an application configuration or transient CI problem, I also tried the following:
- Replaced and reinstalled the preview deploy key, then confirmed GitHub had the updated secret metadata before rerunning the workflow.
- Repeated the workflow after the preview deployment already existed; the backend reused the same named preview deployment successfully, but component discovery still failed.
- Ran the documented one-command flow and the split backend/upload flow. Both reached the same failure at the first component `getUrls` lookup.
- Confirmed the backend and upload steps targeted the same branch-derived preview name.
- Confirmed the generated Convex API contains `components.staticHosting` and the dashboard shows the preview component deployment.
- Tested the same commit, component name, HTTP routing configuration, and static assets with a production-scoped deploy key. Production deployment and a browser smoke test both passed.
- Verified that the failure occurs before asset transfer, so it is unrelated to asset size, WebAssembly MIME handling, cross-origin isolation headers, or the multithreaded WASM runtime.
- Inspected the installed 0.2.1 CLI flow: `deploy` invokes `convex deploy`, then launches the upload flow, which probes `lib:getUrls` through separate `convex run --component ...` calls.
- Compared npm's latest release with the current upstream repository; 0.2.1 is still latest and the current CLI exposes no preview-target or preview-name option for `upload`.
- Searched this repository's open and closed issues/PRs and broader GitHub issue search for an existing preview-deploy-key report, without finding a match.
## Suspected integration boundary
The Convex CLI receives a deployment-scoped admin credential while claiming the preview deployment, but the static-hosting upload runs afterward through separate `convex run --component ...` calls. The original project-level preview key does not appear sufficient for those calls.
Would the preferred fix be a supported post-deploy hook that retains deployment-scoped credentials, a Convex CLI API for executing against the claimed preview deployment, or first-class preview handling inside the static-hosting CLI?
I would be interested in contributing a patch once the intended credential flow is clarified.
Contributor guide
Research direction
Start with the static-hosting CLI flow described for deploy and upload, especially the separate convex run --component calls that probe lib:getUrls, and compare it with the successful convex deploy step. The intended credential flow or preview-target API still needs clarification; done means preview deployments can complete the backend deployment and asset upload with a project-level preview key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100