Skip to content

feature/deploy#39

Open
sreyasppradeep1455 wants to merge 3 commits intomainfrom
feature/deploy
Open

feature/deploy#39
sreyasppradeep1455 wants to merge 3 commits intomainfrom
feature/deploy

Conversation

@sreyasppradeep1455
Copy link
Copy Markdown
Collaborator

Fix: Correct deploy endpoint with proper host preservation through proxy

Problem

When deploying functions, the CLI displayed an incorrect deployment URL that always showed localhost regardless of the actual server IP address. This happened because requests going through the proxy lost the original client host information.

Root Cause

  • The reverse proxy was forwarding requests to localhost:8080 (runtime-manager)
  • The runtime-manager only saw the proxy's internal Host header (localhost)
  • The deploy API generated endpoints based on this incorrect host

Solution

  1. Proxy Enhancement: Added X-Forwarded-Host header to preserve the original client host when forwarding requests to the runtime-manager
  2. Deploy API Update: Modified the endpoint generation logic to:
    • Check for X-Forwarded-Host header first (set by proxy)
    • Fall back to direct r.Host if no proxy header
    • Use conditional logic: localhost for local dev, {ip}.nip.io for remote addresses

Changes

  • internal/proxy/proxy.go: Added X-Forwarded-Host header for control plane requests
  • internal/api/deploy.go: Updated host detection and endpoint formatting logic
  • internal/service/deploy_service.go: Service layer updates

Testing

Deploy a function and verify the output URL now shows:

  • Local dev: http://functionname.localhost
  • Remote: http://functionname.{ip}.nip.io
  • Example: http://calc.10.30.20.196.nip.io

Fixes

  • ✅ Correct IP shown in deploy endpoint
  • ✅ nip.io format for remote addresses
  • ✅ Proper localhost handling for development
  • ✅ Test suite passing (fixed flaky TestBuildImage_duplicateImageName)

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.

1 participant