Skip to content

Migrate API URLs to data.cambeerfestival.app custom domain with relative URL support - #138

Merged
richardthe3rd merged 4 commits into
mainfrom
copilot/update-data-source-url
Dec 14, 2025
Merged

Migrate API URLs to data.cambeerfestival.app custom domain with relative URL support#138
richardthe3rd merged 4 commits into
mainfrom
copilot/update-data-source-url

Conversation

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Replace Cloudflare worker default URLs (cbf-data-proxy.richard-alcock.workers.dev) with custom domain (data.cambeerfestival.app) to consolidate CORS configuration under app control. Implements relative URL support in festivals.json for improved portability.

Changes

Application code:

  • lib/services/festival_service.dart - festivals registry endpoint, added relative URL resolution
  • lib/models/festival.dart - default festival data URLs
  • data/festivals.json - all festival configurations now use relative URLs (/cbf2025 instead of absolute URLs)

Tests:

  • test/models_test.dart - URL validation tests
  • test/services_test.dart - added test for relative URL resolution, updated all FestivalsResponse tests
  • test/beer_provider_test.dart - updated provider tests
  • test/main_test.dart - updated main tests
  • test/brewery_screen_test.dart - updated screen tests
  • test-e2e/screenshots.ts - E2E API base constant

Documentation:

  • API reference docs (docs/api/)
  • JSON schema $id fields
  • docs/api/festival-registry-schema.json - documented relative URL support
  • Network allowlist
  • README examples

Key Features

Relative URL Support: festivals.json now uses relative paths (e.g., /cbf2025) instead of absolute URLs. The FestivalService automatically resolves these to absolute URLs based on where festivals.json was fetched from. This makes festivals.json portable across different domains without requiring modifications.

Benefits:

  • Single source of truth for API base URL (determined by where festivals.json is served from)
  • festivals.json can be served from any domain without modification
  • Improved maintainability - no need to update URLs when changing domains

All 308 tests pass. No breaking changes to existing functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>Use data.cambeerfestival.app for festival and drinks data instead of the cloudflare provided url</issue_title>
<issue_description>We have configured a custom domain for the cloudflare workers for data.

This should be used instead of the current address.

Look for all places that need to be updated.

Use ./bin/mise to access flutter

Ask questions to clarify scope.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: richardthe3rd <573334+richardthe3rd@users.noreply.github.com>
Copilot AI changed the title [WIP] Update festival and drinks data source URL Migrate API URLs to data.cambeerfestival.app custom domain Dec 14, 2025
Copilot AI requested a review from richardthe3rd December 14, 2025 11:06
@github-actions

github-actions Bot commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

LCOV of commit 6a26a77 during Flutter App CI/CD #775

Summary coverage rate:
  lines......: 62.6% (1607 of 2568 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate:
                                       |Lines       |Functions  |Branches    
  Filename                             |Rate     Num|Rate    Num|Rate     Num
  ===========================================================================
  lib/models/festival.dart             | 0.0%    108|    -     0|    -      0
  lib/services/festival_service.dart   | 0.0%     36|    -     0|    -      0

@codecov

codecov Bot commented Dec 14, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

📸 App Screenshots

Visual preview of the app after your changes:

Screen Preview (Mobile 390x844)
Drinks list Drinks list

Screenshots are automatically generated for PRs targeting main branch when app files change.

github-actions Bot added a commit that referenced this pull request Dec 14, 2025
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Cloudflare Pages Preview

Your preview deployment is ready!

Preview URL: https://copilot-update-data-source-u.staging-cambeerfestival.pages.dev

This preview will be automatically updated when you push new commits to this PR.

@richardthe3rd

Copy link
Copy Markdown
Owner

@copilot are there cors related updates we need to make. The screenshots and staging deployment show error loading drinks.

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown
Contributor Author

@copilot are there cors related updates we need to make. The screenshots and staging deployment show error loading drinks.

The error is caused by a deployment sequencing issue:

  1. The app code now points to data.cambeerfestival.app
  2. But the worker at that domain is still serving the old festivals.json with URLs pointing to cbf-data-proxy.richard-alcock.workers.dev
  3. This creates a URL mismatch

Solution: When this PR merges to main, the GitHub Actions workflow will automatically redeploy the Cloudflare Worker with the updated data/festivals.json (the workflow triggers on changes to this file). This will sync the worker's data with the app's expectations.

The staging/preview deployments are failing because they're fetching from the new domain before the worker has been updated with the new festivals.json data.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • data.cambeerfestival.app
    • Triggering command: /usr/bin/curl curl -i REDACTED (dns block)
  • mise-versions.jdx.dev
    • Triggering command: /home/REDACTED/work/cambridge-beer-festival-app/cambridge-beer-festival-app/.mise/mise-2025.11.10 /home/REDACTED/work/cambridge-beer-festival-app/cambridge-beer-festival-app/.mise/mise-2025.11.10 run test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@richardthe3rd

Copy link
Copy Markdown
Owner

@copilot should festivals.json have relative rather than absolute URLs? Would be more portable? App may need updating?

Co-authored-by: richardthe3rd <573334+richardthe3rd@users.noreply.github.com>

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown
Contributor Author

@copilot should festivals.json have relative rather than absolute URLs? Would be more portable? App may need updating?

Good idea! Changed festivals.json to use relative URLs (/cbf2025 instead of absolute URLs). The app now resolves these relative to where festivals.json was fetched from, making it portable across different domains.

Changes in commit edbbbf4:

  • festivals.json uses relative paths for data_base_url
  • FestivalService resolves relative URLs to absolute at runtime
  • All 308 tests updated and passing

This means festivals.json can be served from any domain without modification - the worker just needs to serve it, and the app will automatically construct the correct absolute URLs.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mise-versions.jdx.dev
    • Triggering command: /home/REDACTED/work/cambridge-beer-festival-app/cambridge-beer-festival-app/.mise/mise-2025.11.10 /home/REDACTED/work/cambridge-beer-festival-app/cambridge-beer-festival-app/.mise/mise-2025.11.10 run test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: richardthe3rd <573334+richardthe3rd@users.noreply.github.com>
Copilot AI changed the title Migrate API URLs to data.cambeerfestival.app custom domain Migrate API URLs to data.cambeerfestival.app custom domain with relative URL support Dec 14, 2025
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Cloudflare Pages Preview

Your preview deployment is ready!

Preview URL: https://copilot-update-data-source-u.staging-cambeerfestival.pages.dev

This preview will be automatically updated when you push new commits to this PR.

@richardthe3rd
richardthe3rd marked this pull request as ready for review December 14, 2025 12:20
Copilot AI review requested due to automatic review settings December 14, 2025 12:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR successfully migrates the Cambridge Beer Festival app from using the default Cloudflare worker URL (cbf-data-proxy.richard-alcock.workers.dev) to a custom domain (data.cambeerfestival.app), while introducing a flexible relative URL resolution mechanism for festival configurations. This change consolidates CORS configuration under app control and makes the festivals.json configuration file portable across different deployment environments.

Key Changes

  • Custom domain migration: All API endpoints now use data.cambeerfestival.app instead of the Cloudflare worker default URL
  • Relative URL support: Festival configurations in festivals.json now use relative paths (/cbf2025) that are automatically resolved based on where the registry is fetched from
  • Enhanced portability: The festivals configuration can now be served from any domain without modification, as URLs are resolved dynamically at runtime

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/services/festival_service.dart Implements relative URL resolution logic in fromJson factory; extracts base URL from festivals endpoint; adds baseUrl field to FestivalsResponse
lib/models/festival.dart Updates default festival dataBaseUrl values from old Cloudflare worker URL to new custom domain
data/festivals.json Migrates all festival configurations from absolute URLs to relative paths (/cbf2025, /cbfw2025, /cbf2024)
test/services_test.dart Adds baseUrl parameter to all fromJson calls; includes new test case verifying relative URL resolution behavior
test/models_test.dart Updates URL expectations in festival tests to use new custom domain
test/main_test.dart Adds baseUrl parameter to FestivalsResponse constructor in test setup
test/brewery_screen_test.dart Adds baseUrl parameter to test festival response setup
test/beer_provider_test.dart Updates all 10 test cases to include baseUrl parameter in FestivalsResponse constructors
test-e2e/screenshots.ts Updates API_BASE_URL constant from old worker URL to custom domain
docs/api/festival-registry-schema.json Updates $id to new domain; removes format: "uri" constraint; documents relative URL support with updated description and examples
docs/api/data-api-reference.md Updates all API base URL references and example endpoints to use custom domain
docs/api/beer-list-schema.json Updates schema $id to reference new custom domain
docs/api/README.md Updates base URL references and code examples (JavaScript, Python) to use custom domain
docs/PLAY_STORE_METADATA.md Updates API endpoint documentation from old worker URL to custom domain
docs/NETWORK_ALLOWLIST.md Updates domain allowlist entries and example URLs to reference custom domain
docs/CLOUDFLARE_PAGES_SETUP.md Updates worker deployment documentation and verification examples with new domain
docs/CICD.md Updates worker URL references in CI/CD deployment documentation
cloudflare-worker/README.md Updates example URL in code comments to use new custom domain pattern
README.md Updates Data API section with new base URL and example endpoint
CLAUDE.md Updates API details section with new base URL
.github/copilot-instructions.md Updates API section base URL from old worker URL to custom domain

@richardthe3rd
richardthe3rd merged commit 0a09f01 into main Dec 14, 2025
21 checks passed
@richardthe3rd
richardthe3rd deleted the copilot/update-data-source-url branch December 14, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use data.cambeerfestival.app for festival and drinks data instead of the cloudflare provided url

3 participants