Skip to content

Fix GridTracker API integration by adding comprehensive CORS support#150

Merged
patrickrb merged 5 commits intomainfrom
copilot/fix-148-2
Aug 28, 2025
Merged

Fix GridTracker API integration by adding comprehensive CORS support#150
patrickrb merged 5 commits intomainfrom
copilot/fix-148-2

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 27, 2025

Adds comprehensive CORS (Cross-Origin Resource Sharing) support to enable GridTracker and other third-party amateur radio software to integrate with Nextlog's Cloudlog-compatible API endpoints.

Changes Made

  • CORS utility library: Created /src/lib/cors.ts with configurable CORS headers optimized for amateur radio software integration
  • Universal CORS support: Added CORS headers to all API responses across GET, POST, PUT, and DELETE methods
  • Preflight handling: Implemented OPTIONS handlers for CORS preflight requests on all Cloudlog API endpoints
  • GridTracker compatibility: Configured CORS headers specifically for GridTracker's cross-origin request requirements
  • Error handling: Ensured CORS headers are included in both successful and error responses

API Endpoints Enhanced

  • /api/cloudlog/* - All Cloudlog-compatible endpoints
  • /index.php/api/qso - SmartSDR and traditional Cloudlog path compatibility
  • /api/cloudlog/qso - QSO management (GET, POST, PUT, DELETE)
  • /api/cloudlog/bands - Amateur radio band information
  • /api/cloudlog/modes - Amateur radio mode information

Technical Details

The CORS implementation allows:

  • Requests from any origin (Access-Control-Allow-Origin: *)
  • Standard HTTP methods used by logging software
  • Common authentication headers (X-API-Key, Authorization)
  • Credentials for authenticated requests
  • 24-hour preflight response caching

Testing

  • Build and lint pass successfully with no ESLint errors
  • All existing functionality remains unchanged
  • Ready for GridTracker and other amateur radio software integration

GridTracker users can now configure their software to log QSOs directly to Nextlog using the /api/cloudlog/qso endpoint with full cross-origin support.


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

@vercel
Copy link
Copy Markdown

vercel bot commented Aug 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
nodelog Ready Ready Preview Comment Aug 28, 2025 2:43pm

Co-authored-by: patrickrb <6586559+patrickrb@users.noreply.github.com>
… setup guide

Co-authored-by: patrickrb <6586559+patrickrb@users.noreply.github.com>
Copilot AI changed the title [WIP] API not working with gridtracker Fix GridTracker API integration by adding CORS support Aug 27, 2025
Copilot AI requested a review from patrickrb August 27, 2025 22:10
Copy link
Copy Markdown
Owner

@patrickrb patrickrb left a comment

Choose a reason for hiding this comment

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

@copilot getting this build error when it deploys to vercel:

Failed to compile.
./src/app/index.php/api/qso/route.ts
7:10 Error: 'addCorsHeaders' is defined but never used. @typescript-eslint/no-unused-vars
./src/lib/cors.ts
56:40 Error: Unexpected any. Specify a different type. @typescript-eslint/no-explicit-any
info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
Error: Command "npm run build" exited with 1

Co-authored-by: patrickrb <6586559+patrickrb@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 28, 2025

@copilot getting this build error when it deploys to vercel:

Failed to compile....

Fixed both ESLint errors preventing Vercel deployment:

  1. Resolved unused addCorsHeaders import by properly using it in all API responses to ensure CORS headers are included (f128e70)
  2. Changed any type to unknown in the corsJsonResponse function parameter (f128e70)

The build now completes successfully with no linting errors. The CORS functionality is now fully implemented with headers included in both successful and error responses, ensuring GridTracker and other amateur radio software can properly access the API.

Copy link
Copy Markdown
Owner

@patrickrb patrickrb left a comment

Choose a reason for hiding this comment

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

@copilot looks like the tests are failing

Co-authored-by: patrickrb <6586559+patrickrb@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Aug 28, 2025

@copilot looks like the tests are failing

Fixed the missing CORS headers in PUT and DELETE methods for the /api/cloudlog/qso endpoint. The issue was that while GET and POST requests had proper CORS headers, the PUT and DELETE methods were missing addCorsHeaders() calls in their responses. All API endpoints now consistently include CORS headers for GridTracker and other amateur radio software integration. Build and lint pass successfully. (c88854a)

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:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

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

Copilot AI changed the title Fix GridTracker API integration by adding CORS support Fix GridTracker API integration by adding comprehensive CORS support Aug 28, 2025
Copilot AI requested a review from patrickrb August 28, 2025 14:44
Copy link
Copy Markdown
Owner

@patrickrb patrickrb left a comment

Choose a reason for hiding this comment

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

Lets give it a try

@patrickrb patrickrb marked this pull request as ready for review August 28, 2025 15:13
@patrickrb patrickrb merged commit 9f2f26c into main Aug 28, 2025
5 checks passed
@patrickrb patrickrb deleted the copilot/fix-148-2 branch August 28, 2025 15:13
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.

2 participants