feat: Add PREEVY_HOST and PREEVY_ENV_ID environment variables#603
Draft
feat: Add PREEVY_HOST and PREEVY_ENV_ID environment variables#603
Conversation
Copilot
AI
changed the title
[WIP] [Feat]: Adding more preevy environment variables
feat: Add PREEVY_HOST and PREEVY_ENV_ID environment variables
Sep 29, 2025
Yshayy
requested changes
Sep 29, 2025
| ): Record<string, string> => { | ||
| const baseUriVars = Object.fromEntries( | ||
| expectedServiceUrls | ||
| .map(({ name, port, url }) => [`PREEVY_BASE_URI_${name.replace(/[^a-zA-Z0-9_]/g, '_')}_${port}`.toUpperCase(), url]) |
Contributor
There was a problem hiding this comment.
the regex replace can be extracted to format service name for url function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two new environment variables to enhance Preevy's service discovery capabilities, addressing specific user needs while maintaining full backward compatibility.
New Environment Variables
PREEVY_ENV_ID- Contains the environment ID (e.g.,my-app-main)PREEVY_HOST_{SERVICE}_{PORT}- Contains just the hostname without protocol or trailing slash (e.g.,frontend-3000-envid-clientid.livecycle.run)Problem Solved
Users reported limitations with the existing
PREEVY_BASE_URI_{SERVICE}_{PORT}variables:Example Usage
Before:
After:
Implementation Details
serviceLinkEnvVars()function to generate additional environment variablesURLconstructor with graceful fallback for invalid URLsBackward Compatibility
✅ All existing
PREEVY_BASE_URI_{SERVICE}_{PORT}variables work exactly as before✅ No breaking changes to existing functionality
✅ New variables are additive only
Testing
Documentation
Updated service discovery documentation with examples showing how to use all three types of environment variables together.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.