-
-
Notifications
You must be signed in to change notification settings - Fork 46
Add automatic GitHub release check with .zip support, CORS proxy, and certificate expiration handling #690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
|
@copilot Checking for new firmware should also happen in the client browser. You can get the currently running firmware version from the client already by requesting "/configJSON" . It returns a JSON string with a bunch of useful information in it including the firmware version. That should reduce a lot more of the code you currently have added on the server. |
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Done in commit a9536f7. All GitHub API querying now happens in the browser:
Changes:
Result: Net -36 lines of code, zero new ESP32 code. |
|
@copilot I'm getting "No firmware assets found in release". I'm guessing that's because the firmware is in a .zip file. Also, We don't need a button to check for updates. This should be done automatically when the page loads, and if we don't have internet or can't connect to github for some reason, just not display the related info and update button. Here is the payload from github.com to help you fix the issue with no firmware assets being found: { |
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Done in commit cf9993b. The implementation now:
The asset detection now matches the actual release format from your payload: if (assetName.endsWith('.bin.zip') || assetName.endsWith('.bin')) |
|
@copilot There's a CORS issue when trying to download. How can we work around this while keeping everything browswer based? |
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Fixed in commit 3d7f159. The ESP32 now acts as a proxy to work around CORS restrictions: The Solution:
Why this works:
|
|
@copilot One of my concerns is that since the server CA certificate is stored on the ESP32, if the certificate expires, then the automatic update won't work. Can we send the current certificate for github as part of the request to the ESP32 and use that one instead of the firmware bundled certificate? |
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Fixed in commit 8a031e5. The implementation now handles certificate expiration automatically: Approach:
Why this is safe:
This solves the chicken-and-egg problem: even if the certificate expires, users can still update to newer firmware that has an updated certificate. |



Users must manually download firmware from GitHub releases and upload via the web interface. This adds automatic update checking and one-click installation directly from the OTA page.
Changes
Backend
/downloadFirmwareproxy endpoint to work around CORS restrictions/configJSON- ReturnsfirmwareVersionfor version comparisonFrontend
Enhanced OTA page with automatic update checking and two-phase update flow:
Automatic Check on Page Load
/configJSONfrom device to get current firmware versionhttps://api.github.com/repos/doudar/SmartSpin2k/releases/latestAsset Detection & Extraction
.binand.bin.zipfile formatsSmartSpin2kFirmware-25.11.3.bin.zip.binfile from zip in browser before uploadCORS Workaround
/downloadFirmware?url=...(same origin, no CORS issue)Certificate Expiration Handling
setInsecure()Phase 1: Display Results
Phase 2: Install
.binfile in browser/updateendpoint (green progress bar)Implementation Details
Key design:
/configJSONArchitecture
CORS Solution
Problem: GitHub's
browser_download_urldoesn't set CORS headers, blocking direct browser downloads.Solution: ESP32 proxy server
Certificate Expiration Solution
The Problem: Bundled CA certificate will eventually expire, preventing automatic updates (chicken-and-egg problem).
The Solution: Automatic fallback
Why this is safe:
Screenshot
GitHub Release section automatically appears when page loads (if update available), or remains hidden if GitHub is unreachable.
Benefits
/configJSON.bin.zipformat from GitHub releasesOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.