This guide will walk you through deploying the AI Prompt Dashboard to Cloudflare Pages, allowing you to access your prompts from anywhere.
- A Cloudflare account
- Wrangler CLI installed (optional, for local testing)
- Git repository with your project (GitHub, GitLab, or Bitbucket)
This repository includes a GitHub Actions workflow that automatically deploys to Cloudflare Pages when changes are pushed to the main branch.
-
Set up Cloudflare API tokens:
- Log in to your Cloudflare dashboard
- Navigate to "My Profile" > "API Tokens"
- Create a new token with the "Edit Cloudflare Pages" template
- Copy the token value
-
Add repository secrets:
- Go to your GitHub repository
- Navigate to "Settings" > "Secrets and variables" > "Actions"
- Add the following secrets:
CLOUDFLARE_API_TOKEN: Your Cloudflare API tokenCLOUDFLARE_ACCOUNT_ID: Your Cloudflare account ID (found in the dashboard URL)
-
Trigger deployment:
- Push changes to the
mainbranch - The workflow will automatically build and deploy your application
- Check the "Actions" tab in your GitHub repository for deployment status
- Once complete, you'll receive a URL to access your application (e.g.,
https://ai-prompt-dashboard.pages.dev)
- Push changes to the
-
Connect your GitHub repository to Cloudflare Pages:
- Log in to your Cloudflare dashboard
- Navigate to "Pages"
- Click "Create a project"
- Select "Connect to Git"
- Authorize Cloudflare to access your GitHub account
- Select the
prompt-dashboardrepository
-
Configure build settings:
- Project name:
ai-prompt-dashboard(or your preferred name) - Production branch:
main(or your default branch) - Build command:
npm run build - Build output directory:
dist - Node.js version:
20(or latest LTS)
- Project name:
-
Add environment variables (if needed):
- No environment variables are required for basic functionality
- For custom Supabase integration, you can configure it in the app settings
-
Deploy:
- Click "Save and Deploy"
- Cloudflare will build and deploy your application
- Once complete, you'll receive a URL to access your application (e.g.,
https://ai-prompt-dashboard.pages.dev)
-
Install Wrangler CLI (if not already installed):
npm install -g wrangler
-
Log in to Cloudflare:
wrangler login
-
Build your project:
npm run build
-
Deploy to Cloudflare Pages:
wrangler pages deploy dist
-
Follow the prompts to complete the deployment.
- In your Cloudflare Pages project, go to "Custom domains"
- Click "Set up a custom domain"
- Follow the instructions to add your domain
The application allows you to configure Supabase directly in the UI:
- Access your deployed application
- Click the settings icon in the top-right corner
- Select "Supabase" or "Both" as your storage option
- Enter your Supabase project URL and anon key
- Click "Save"
Simply push changes to your connected GitHub repository. Cloudflare will automatically build and deploy the updates.
- Make your changes
- Build the project:
npm run build - Deploy the updates:
wrangler pages deploy dist
This application is a single-page application (SPA) that uses client-side routing. To ensure that all routes are handled correctly by Cloudflare Pages, the project includes a _routes.json file in the public directory with the following configuration:
{
"version": 1,
"include": ["/*"],
"exclude": [
"/assets/*",
"/*.png",
"/*.svg",
"/*.jpg",
"/*.ico",
"/*.js",
"/*.css"
],
"serve": {
"/*.html": "/index.html",
"/": "/index.html",
"/*": "/index.html"
}
}This configuration ensures that:
- All routes are included by default
- Static assets are excluded from the SPA routing
- All non-asset routes are served with
index.htmlto support client-side routing
If your build fails, check the build logs in the Cloudflare dashboard for specific errors.
Common issues:
- Node.js version compatibility
- Missing dependencies
- Build script errors
If the application deploys but doesn't work correctly:
- Check browser console for errors
- Verify Supabase connection settings
- Ensure Content Security Policy in
wrangler.tomlallows all required connections - Verify that the
_routes.jsonfile is correctly configured for SPA routing
If you experience routing issues (e.g., 404 errors when navigating to routes directly):
- Verify that the
_routes.jsonfile is correctly configured - Ensure that the
serveproperty is correctly set to serveindex.htmlfor all routes - Check that the file is in the
publicdirectory so it's included in the build output
If you experience CORS issues with Supabase or the Pollinations API:
- Verify the Content Security Policy in
wrangler.toml - Update the
connect-srcdirective if needed
- The application stores data in browser localStorage by default, which is secure and private
- When using Supabase, ensure you're using the anon key (not the service key)
- Consider enabling user authentication for additional security
If you encounter any issues with your Cloudflare Pages deployment, refer to the Cloudflare Pages documentation or reach out to Pink Pixel for assistance.
Made with ❤️ by Pink Pixel