-
Notifications
You must be signed in to change notification settings - Fork 147
Enables local queue origin config via Nitro runtime #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
claylevering
wants to merge
5
commits into
vercel:main
Choose a base branch
from
claylevering:feat/nuxt-nitro-runtime-configs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+102
−2
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c38975e
Enables local queue origin config via Nitro runtime
claylevering 4e55b99
Small change to wording
claylevering 5544d09
Adds changeset for version bump
claylevering 94e156a
Consolidates Nuxt runtime config documentation
claylevering 5cc4824
Update docs/content/docs/deploying/world/local-world.mdx
claylevering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "@workflow/nitro": patch | ||
| "@workflow/nuxt": patch | ||
| "@workflow/world-local": patch | ||
| --- | ||
|
|
||
| Enables local queue origin config via Nitro runtime. | ||
|
|
||
|
|
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { defineNitroPlugin } from 'nitro/~internal/runtime/plugin'; | ||
| import { useRuntimeConfig } from 'nitro/runtime-config'; | ||
|
|
||
| /** | ||
| * Bridge Nitro runtimeConfig -> Workflow local world env vars. | ||
| * | ||
| * This is framework-agnostic: | ||
| * - Works in Nuxt because Nuxt feeds runtimeConfig into Nitro. | ||
| * - Works in standalone Nitro if the user provides `runtimeConfig` in nitro.config. | ||
| * | ||
| * Supported keys: | ||
| * - `runtimeConfig.workflow.baseUrl` (preferred, private/server-only) | ||
| * - `runtimeConfig.public.workflow.baseUrl` (fallback) | ||
| * - `runtimeConfig.workflow.{protocol,host,port}` (preferred) | ||
| * - `runtimeConfig.public.workflow.{protocol,host,port}` (fallback) | ||
| * | ||
| * Result: | ||
| * - Sets `process.env.WORKFLOW_LOCAL_BASE_URL` if not already set. | ||
| */ | ||
| export default defineNitroPlugin(() => { | ||
| if (process.env.WORKFLOW_LOCAL_BASE_URL) return; | ||
|
|
||
| const runtimeConfig = useRuntimeConfig(); | ||
| const workflow = | ||
| runtimeConfig?.workflow ?? runtimeConfig?.public?.workflow ?? undefined; | ||
|
|
||
| if (!workflow) return; | ||
|
|
||
| // Full baseUrl override (recommended) | ||
| if (typeof workflow.baseUrl === 'string' && workflow.baseUrl.length > 0) { | ||
| process.env.WORKFLOW_LOCAL_BASE_URL = workflow.baseUrl; | ||
| return; | ||
| } | ||
|
|
||
| // Construct from parts (protocol/host/port) | ||
| const protocol = | ||
| typeof workflow.protocol === 'string' && workflow.protocol.length > 0 | ||
| ? workflow.protocol | ||
| : undefined; | ||
| const host = | ||
| typeof workflow.host === 'string' && workflow.host.length > 0 | ||
| ? workflow.host | ||
| : undefined; | ||
| const port = | ||
| typeof workflow.port === 'number' || typeof workflow.port === 'string' | ||
| ? String(workflow.port) | ||
| : undefined; | ||
|
|
||
| if (!protocol || !host) return; | ||
| process.env.WORKFLOW_LOCAL_BASE_URL = port | ||
| ? `${protocol}://${host}:${port}` | ||
| : `${protocol}://${host}`; | ||
| }); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.