#No address provided to ConvexReactClient (fly.io/vite/react/bun/convex/clerk)

12 messages · Page 1 of 1 (latest)

sterile crescent
#

I deployed my react + vite app to fly and added the VITE_CONVEX_URL secret and it still does not work. please advise

#
const convexClient = new ConvexReactClient(
  import.meta.env.VITE_CONVEX_URL as string
);
#

proof of secrets

#

error in browser console when navigating to deployed page:

Uncaught Error: No address provided to ConvexReactClient.
If trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/
If running locally, make sure to run `convex dev` and ensure the .env.local file is populated.
    at new y1 (index-DuoI8RP_.js:65:37620)
    at index-DuoI8RP_.js:65:50440
steady echo
#

i believe Vite builds your app into static assets, so the VITE_CONVEX_URL gets baked into the app at build-time, not runtime. (see https://www.reddit.com/r/reactjs/comments/112y0ht/are_env_on_vite_process_at_runtime_or_buildtime/ and https://community.fly.io/t/vite-react-app-not-loading-fly-secrets/18468 ). If you can set VITE_CONVEX_URL in the dockerfile before running npm run build, that should work.

Reddit

Explore this post and more from the reactjs community

#

as an aside, that VITE_CONVEX_DEPLOY_KEY looks sus. deploy keys allow full access to your deployment's database, so they shouldn't be available to your frontend; it should only be available to the npx convex deploy command.

sterile crescent
#

Resolution:

You can add build-time secrets in your Dockerfile using the ARG instruction. Here's how to modify your Dockerfile to accept build arguments:

# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.29
FROM oven/bun:${BUN_VERSION}-slim AS base

# Add build arguments after FROM
ARG VITE_CONVEX_URL
ARG VITE_CLERK_PUBLISHABLE_KEY

LABEL fly_launch_runtime="Bun"

# Set environment variables from build arguments
ENV VITE_CONVEX_URL=$VITE_CONVEX_URL
ENV VITE_CLERK_PUBLISHABLE_KEY=$VITE_CLERK_PUBLISHABLE_KEY

# ... existing code ...

# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3

# Install node modules
COPY bun.lockb package.json ./
RUN bun install

# Copy application code
COPY . .

# Build application
RUN bun --bun run build

# ... rest of existing code ...

Then when deploying with Fly.io, you would pass these build arguments:
fly deploy --build-arg VITE_CONVEX_URL="your-convex-url" --build-arg VITE_CLERK_PUBLISHABLE_KEY="your-clerk-key"

#

This issue is resolved but got a new error 🙂

chilly siren
#

@sterile crescent were you able to post your new error somewhere else? I saw a mod bot message about something being deleted

sterile crescent