[PR #240] [MERGED] fix: Handle HTTP redirects in workflow curl requests #256

Closed
opened 2026-02-27 09:13:57 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/maillab/cloud-mail/pull/240
Author: @ifsheldon
Created: 1/21/2026
Status: Merged
Merged: 1/22/2026
Merged by: @eoao

Base: mainHead: main


📝 Commits (2)

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 .github/workflows/deploy-cloudflare.yml (+2 -2)

📄 Description

Summary

Fix deployment workflow failures caused by HTTP redirects when CUSTOM_DOMAIN is configured without the https:// protocol prefix.

Problem

When users configure CUSTOM_DOMAIN without the protocol (e.g., mail.example.com instead of https://mail.example.com), the curl requests fail because:

  1. HTTP 301 redirects are not followed - The server redirects HTTP → HTTPS, but curl doesn't follow redirects by default, resulting in:

    ❌ Failed. HTTP: 301, Response: 
    
  2. POST body is lost on redirect - Even with -L (follow redirects), curl converts POST → GET when following 301/302 redirects, causing the JSON body to be discarded. This results in:

    {"code": 500, "message": "Unexpected end of JSON input"}
    

Solution

Commit 1: Add -L flag to follow redirects (d0800cf)

  • Added -L flag to both curl commands in the "Initialize database" and "Set up email receiving" steps
  • This allows curl to automatically follow HTTP → HTTPS redirects

Commit 2: Preserve POST method through redirects (eebf38a)

  • Added --post301 --post302 --post303 flags to the POST request in "Set up email receiving" step
  • This ensures the POST method and request body are preserved when following redirects

Changes

File Changes
.github/workflows/deploy-cloudflare.yml Modified curl commands to handle redirects properly

Testing

  • Tested with CUSTOM_DOMAIN set without https:// prefix
  • Both "Initialize database" and "Set up email receiving" steps now complete successfully

Recommendation

For best results, users should still configure CUSTOM_DOMAIN with the full URL including protocol:

https://mail.example.com

This avoids the redirect overhead entirely.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maillab/cloud-mail/pull/240 **Author:** [@ifsheldon](https://github.com/ifsheldon) **Created:** 1/21/2026 **Status:** ✅ Merged **Merged:** 1/22/2026 **Merged by:** [@eoao](https://github.com/eoao) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`d0800cf`](https://github.com/maillab/cloud-mail/commit/d0800cf4f9713b996f3be7ca0f877783ee8e3f49) update workflow - [`eebf38a`](https://github.com/maillab/cloud-mail/commit/eebf38a99a861b13a3ca14b883ce1bbc6367569d) fix workflow ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/deploy-cloudflare.yml` (+2 -2) </details> ### 📄 Description ## Summary Fix deployment workflow failures caused by HTTP redirects when `CUSTOM_DOMAIN` is configured without the `https://` protocol prefix. ## Problem When users configure `CUSTOM_DOMAIN` without the protocol (e.g., `mail.example.com` instead of `https://mail.example.com`), the curl requests fail because: 1. **HTTP 301 redirects are not followed** - The server redirects HTTP → HTTPS, but curl doesn't follow redirects by default, resulting in: ``` ❌ Failed. HTTP: 301, Response: ``` 2. **POST body is lost on redirect** - Even with `-L` (follow redirects), curl converts POST → GET when following 301/302 redirects, causing the JSON body to be discarded. This results in: ```json {"code": 500, "message": "Unexpected end of JSON input"} ``` ## Solution ### Commit 1: Add `-L` flag to follow redirects (`d0800cf`) - Added `-L` flag to both curl commands in the "Initialize database" and "Set up email receiving" steps - This allows curl to automatically follow HTTP → HTTPS redirects ### Commit 2: Preserve POST method through redirects (`eebf38a`) - Added `--post301 --post302 --post303` flags to the POST request in "Set up email receiving" step - This ensures the POST method and request body are preserved when following redirects ## Changes | File | Changes | |------|---------| | `.github/workflows/deploy-cloudflare.yml` | Modified curl commands to handle redirects properly | ## Testing - Tested with `CUSTOM_DOMAIN` set without `https://` prefix - Both "Initialize database" and "Set up email receiving" steps now complete successfully ## Recommendation For best results, users should still configure `CUSTOM_DOMAIN` with the full URL including protocol: ``` https://mail.example.com ``` This avoids the redirect overhead entirely. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 09:13:57 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cloud-mail-maillab#256
No description provided.