Inject Portless URLs into environment variables
Problem
I use portless across several repos with multiple apps and worktrees. Those apps often need each other's portless URLs through environment variables such as APP_URL, API_URL, or AUTH_URL.
Right now, each project contains a helper that runs portless get <name> and copies the result into process.env. It works, but it couples application configuration to the portless CLI and duplicates the same code across our repos.
Desired behavior
When portless launches a development process, I'd like it to resolve a declared mapping between environment variables and Portless names:
APP_URL -> web
API_URL -> api
AUTH_URL -> authThe child process would receive the worktree-aware URLs without application code calling portless get.
This could be configured declaratively, or through a command such as:
portless env APP_URL=web API_URL=api AUTH_URL=auth -- pnpm devI'm not attached to that interface. The outcome I'm after is:
- No portless-specific subprocess calls in application source
- One declarative mapping per project
- Correct URLs for the current worktree
- Support for one app referring to other Portless apps
Does portless already have a preferred way to handle this, or would it fit the project's scope?
Source: vercel-labs/portless