Skip to content

Conversation

Copy link

Copilot AI commented Dec 8, 2025

  • Add CORS support to allow requests from https://abundance.maslowcnc.com/
    • Add CORS headers to relevant endpoints (/upload, /files, etc.)
    • Add CORS headers to root handler (/)
    • Add CORS headers to not_found handler
    • Add CORS headers to myStreamFile function
    • Handle OPTIONS preflight requests on all endpoints
    • Add helper functions sendCORSHeaders() and handleCORSPreFlight()
  • Create API documentation for external gcode file uploads
    • Document the /upload endpoint (SD card)
    • Document the /files endpoint (LocalFS)
    • Provide example code for file upload from external website
    • Include authentication requirements
    • Add complete MaslowUploader class example
    • Create abundance.maslowcnc.com integration guide
    • Create CORS implementation summary
  • Test CORS functionality
    • Build firmware to ensure no compilation errors
    • Verify code formatting with clang-format
    • Check for trailing whitespace
  • Address code review feedback
    • Fix sendJSON to use the code parameter instead of hardcoded 200
  • Add "Link Abundance" button
    • Move button to calibration_popup_content div as requested
    • Position button after "Config" button
    • Fix IP address to use websocket_ip (actual IP) instead of hostname
    • Rebuild web UI with updated button location
    • Verify firmware builds successfully
  • Fix CORS connection test issue
    • Add CORS headers to root handler for connection test requests
    • Add CORS headers to not_found handler
    • Add CORS headers to file streaming function
Original prompt

This section details on the original issue you should resolve

<issue_title>Upload gcode files directly</issue_title>
<issue_description>We are currently using the "upload gcode" button to select and upload gcode files to the machine.

In addition to being able to do that we would like to be able to send gcode files to the machine directly from the website https://abundance.maslowcnc.com/

Please enable CORS for that site and generate a prompt containing all of the information that site will need to be able to send a gcode file directly to maslow.</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.

Copilot AI changed the title [WIP] Enable CORS for direct gcode file uploads Enable CORS for abundance.maslowcnc.com file uploads Dec 8, 2025
Copilot AI requested a review from BarbourSmith December 8, 2025 05:49
@BarbourSmith
Copy link
Member

@copilot The process of getting the machine's IP address to upload files automatically is confusing for users.

Please add a button to the settings menu directly below the "Config" button called "Link Abundance" which will open the address https://abundance.maslowcnc.com/?IP=xx.xxx.xxx.xxx with the machine's IP address filled in.

That way the ip address can be saved automatically by abundance.

Copy link
Author

Copilot AI commented Dec 8, 2025

@copilot The process of getting the machine's IP address to upload files automatically is confusing for users.

Please add a button to the settings menu directly below the "Config" button called "Li...

Added the "Link Abundance" button to the settings menu. The button opens https://abundance.maslowcnc.com/?IP=xx.xxx.xxx.xxx with the machine's IP address automatically filled in.

Link Abundance Button

The button is located in the settings tab button row (after the refresh button) and uses a gear icon to match the settings theme. When clicked, it opens Abundance in a new tab with the IP parameter set.

Commit: 6f55e7c

Copilot AI changed the title Enable CORS for abundance.maslowcnc.com file uploads Enable CORS for abundance.maslowcnc.com file uploads and add Link Abundance button Dec 8, 2025
@BarbourSmith
Copy link
Member

@copilot There are two issues with this.

First I meant for the button to be added to the div with ID calibration_popup_content, please move it there.

Second, when I use that button it is linking me to https://abundance.maslowcnc.com/?IP=maslow.local which is not the real IP address. We want to use the actual IP address of the machine

Copy link
Author

Copilot AI commented Dec 9, 2025

@copilot There are two issues with this.

First I meant for the button to be added to the div with ID calibration_popup_content, please move it there.
...

Fixed both issues:

  1. ✅ Moved the button to calibration_popup_content div - it's now positioned after the "Config" button in the calibration setup section
  2. ✅ Updated to use actual IP address - now uses websocket_ip (the actual IP like 192.168.1.100) instead of the hostname (maslow.local)

Link Abundance Button in Calibration Popup

The button now opens https://abundance.maslowcnc.com/?IP=192.168.1.100 with the real IP address.

Commit: 1e6ab56

@BarbourSmith
Copy link
Member

@copilot This is now failing with the following error message in the console:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.4.102/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

and a popup which says:

Cannot connect to Maslow at 192.168.4.102. Please check:
- The IP address is correct
- The Maslow is powered on
- The Maslow is on the same network

Copy link
Author

Copilot AI commented Dec 9, 2025

@copilot This is now failing with the following error message in the console:

`Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.4.102/. (...

Fixed the CORS issue. The problem was that CORS headers were only being sent for specific endpoints (/upload, /files) but not for the root endpoint (/) that Abundance uses to test the connection.

Added CORS headers to:

  • handle_root() - Root endpoint handler
  • handle_not_found() - 404 handler
  • myStreamFile() - File serving function

All endpoints now include OPTIONS preflight handling and send the Access-Control-Allow-Origin header with every response.

The connection test from abundance.maslowcnc.com should now work correctly.

Commit: 7bc986f

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.

Upload gcode files directly

2 participants