fix(api): accept GridTracker's auth POST and path-segment-key station_info#206
Merged
Conversation
… shape
GridTracker's Cloudlog client (inspected via app.asar src) sends
requests that don't quite match what nextlog implemented:
1. POST {URL}/index.php/api/auth/{KEY} (not GET)
2. POST {URL}/index.php/api/station_info/{KEY} (key in path, no body)
Our /api/auth/[key] only exported GET → Vercel returned 405 Method Not
Allowed with an empty body → GT logged "Invalid Response" and stalled
at "Testing API Key". Our /api/station_info only accepted the key in
the JSON body, so /api/station_info/{KEY} 404'd → after auth's "OK"
the profile-fill response was empty → GT overwrote "OK" with the same
"Invalid Response" message.
This commit:
- /api/auth/[key]: alias GET and POST to one handler; add an OPTIONS
handler for CORS preflight. Matches wavelog/CodeIgniter behavior
where controllers respond to any HTTP method.
- /api/station_info/[key]: new dynamic route, POST + GET both supported
- /api/station_info (body form) preserved as-is, no breaking change
- Extract shared lookup logic into src/lib/station-info.ts so both
routes return identical wavelog-shape JSON
Verified GT's full flow by reading
C:\Users\burns\AppData\Local\Programs\GridTracker2\resources\app.asar
src/renderer/lib/adif.js — functions CloudlogTest,
CloudlogGetProfiles, CloudlogTestApiKey, CloudlogFillProfiles.
After this lands, GT's Test button should show "OK" and populate the
station profile dropdown.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two real-world mismatches between GridTracker's Cloudlog client and what nextlog implemented. Verified by inspecting GT's
app.asar(src/renderer/lib/adif.js) — functionsCloudlogTest,CloudlogTestApiKey,CloudlogGetProfiles,CloudlogFillProfiles.Problem 1:
/api/auth/[key]rejected POSTGT POSTs to
{URL}/index.php/api/auth/{KEY}despite the key being in the path. Our handler only exportedGET, so Vercel returned405 Method Not AllowedwithContent-Length: 0. GT's response parser saw an empty buffer and rendered "Invalid Response" — the user's stall at "Testing API Key" followed by "Invalid Response".Fix: alias
GETandPOSTto a single handler. Also added anOPTIONShandler for CORS preflight. This matches wavelog/CodeIgniter behavior, where the same controller function answers any HTTP method.Problem 2:
/api/station_info/[key]didn't existAfter auth succeeds, GT immediately fetches the station profile list at
{URL}/index.php/api/station_info/{KEY}(key in path, empty body). Our existing/api/station_infoonly read the key from the JSON body, so the dynamic path 404'd → empty buffer → GT overwrote "OK" with "Invalid Response".Fix: new
/api/station_info/[key]/route.tsdynamic route that handles both GET and POST. Existing/api/station_info(body form) is preserved unchanged — both call into a sharedstationInfoResponse(key)helper insrc/lib/station-info.tsso they return byte-identical JSON.What's the same as before
/api/station_info(body form, no path segment) — wire-compatible, no behavior change/api/auth/[key]forGETrequests — same XML response as beforeTest plan
npm run typecheckcleannpm run lintcleanPOST /api/auth/<key>→ 200 XML<status>Valid</status><rights>rw</rights>(was 405)POST /api/station_info/<key>→ 200 JSON station arrayPOST /api/station_info(body form) → 200 JSON station array (regression check, unchanged)How the bug was found
User reported GT stuck at "Testing API Key" then flipping to "Invalid Response". GT's renderer log (
%APPDATA%\GridTracker2\logs\main.log) showedUnexpected token '<'JSON parse errors — confirming GT was getting HTML/empty body instead of expected response. Extracted GT'sapp.asar, read the actualCloudlogTest/CloudlogGetProfilesfunctions, found the two URL forms GT uses.🤖 Generated with Claude Code