fix(leadmail): drop leading slash on post path so Faraday respects /api/v1 prefix
Some checks failed
Lock Threads / action (push) Has been cancelled
Some checks failed
Lock Threads / action (push) Has been cancelled
Faraday treats a leading slash on the request path as absolute from the host root, replacing the path component of the connection URL. With LEADMAIL_API_URL=https://mail.leadmagnet.dev/api/v1 and post('/emails/send'), the resulting URL was https://mail.leadmagnet.dev/emails/send — missing /api/v1, getting an HTML 404 from the LeadMail dispatcher. Drop the leading slash so the path is appended relative to the prefix: https://mail.leadmagnet.dev/api/v1/emails/send Also add Accept: application/json to mirror the documented curl example and avoid any content-negotiation surprises (HTML error pages vs JSON error responses).
This commit is contained in:
@@ -7,7 +7,7 @@ class LeadmailDelivery
|
||||
|
||||
def deliver!(message)
|
||||
payload = build_payload(message)
|
||||
response = http_client.post('/emails/send', payload.to_json)
|
||||
response = http_client.post('emails/send', payload.to_json)
|
||||
|
||||
unless response.success?
|
||||
raise LeadmailDeliveryError, "LeadMail API error: #{response.status} - #{response.body}"
|
||||
@@ -104,7 +104,8 @@ class LeadmailDelivery
|
||||
url: settings[:api_url],
|
||||
headers: {
|
||||
'Authorization' => "Bearer #{settings[:token]}",
|
||||
'Content-Type' => 'application/json'
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user