Skip to content

refactor: auto-enable image proxy handlers from registry config#629

Open
harlan-zw wants to merge 1 commit intomainfrom
refactor/auto-enable-static-maps-proxy
Open

refactor: auto-enable image proxy handlers from registry config#629
harlan-zw wants to merge 1 commit intomainfrom
refactor/auto-enable-static-maps-proxy

Conversation

@harlan-zw
Copy link
Collaborator

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Removes the separate googleStaticMapsProxy module option — the Google Static Maps proxy handler is now auto-registered when registry.googleMaps is configured. The API key and cacheMaxAge are injected into runtime config automatically.

Before:

scripts: {
  registry: { googleMaps: { apiKey: '...' } },
  googleStaticMapsProxy: { enabled: true, cacheMaxAge: 3600 }
}

After:

scripts: {
  registry: { googleMaps: { apiKey: '...' } }
  // proxy auto-enabled, no extra config needed
}

⚠️ Breaking Changes

scripts.googleStaticMapsProxy config option is removed. The proxy now auto-enables when registry.googleMaps is set.

Verification

  • ✅ 263 unit tests pass
  • ✅ Typecheck clean
  • ✅ Lint clean (pre-existing warnings only)
  • ✅ Build succeeds

Remove separate `googleStaticMapsProxy` module option — the handler
is now registered automatically when `registry.googleMaps` is set.
The API key and cacheMaxAge are injected into runtime config from
the registry entry, removing the need for explicit opt-in.
@vercel
Copy link
Contributor

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview, Comment Mar 5, 2026 3:31pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@629

commit: cc51f1d

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

The pull request refactors the Google Static Maps proxy configuration from an explicit module option to a registry-driven approach. The googleStaticMapsProxy option with enabled and cacheMaxAge properties is removed from module options and defaults. Proxy activation now depends on registry.googleMaps presence, with the API key and cache age dynamically merged into the runtime configuration. A conditional check in the component logic is simplified to test for proxy config existence rather than an enabled flag, and the disabled-state guard in the server route handler is removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Details

The changes involve an architectural shift from explicit configuration to registry-driven activation across three files. The logic modifications are straightforward but require verification that the new presence-based checks correctly replace the previous enabled-flag pattern and that removing the server-side guard maintains expected behavior. The heterogeneous nature of changes—module configuration restructuring, component conditional logic simplification, and guard removal—demands separate reasoning for each area, placing this in moderate complexity territory.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main refactor: removing the googleStaticMapsProxy module option and auto-enabling the proxy based on registry.googleMaps config.
Description check ✅ Passed The description follows the template structure, includes type of change (Enhancement), explains the refactor clearly with before/after examples, documents breaking changes, and provides verification results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/auto-enable-static-maps-proxy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue (2)

459-459: ⚠️ Potential issue | 🟠 Major

Inconsistent condition: API key leaks to client when proxy is enabled.

Line 459 checks proxyConfig?.enabled to decide whether to omit the API key from the placeholder URL. Since enabled no longer exists in the config, this always evaluates to undefined (falsy), so apiKey is always included in the query string—even when using the proxy where the key should be injected server-side.

This leaks the API key to the client unnecessarily when the proxy is active.

Update to check for the presence of proxyConfig:

Proposed fix
     // Only include API key if not using proxy (proxy injects it server-side)
-    key: proxyConfig?.enabled ? undefined : apiKey,
+    key: proxyConfig ? undefined : apiKey,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue` at line 459, The
condition that determines whether to include the API key is using
proxyConfig?.enabled which no longer exists and causes apiKey to always be
exposed; update the check in the object where key: proxyConfig?.enabled ?
undefined : apiKey to instead test for the presence of proxyConfig (e.g., key:
proxyConfig ? undefined : apiKey) so when a proxy configuration object exists
the client-side URL omits apiKey; locate this change in ScriptGoogleMaps.vue
around the object that sets key and replace the condition accordingly.

419-428: ⚠️ Potential issue | 🟡 Minor

Inconsistent condition: proxyConfig?.enabled no longer exists.

Line 419 still checks !proxyConfig?.enabled, but the new config structure (per context snippet from module.ts) only contains { cacheMaxAge: 3600 } with no enabled field. This condition will always evaluate to true (since undefined is falsy), causing the preconnect/dns-prefetch link to be added even when the proxy is enabled—which is unnecessary and potentially misleading.

Update to check for the presence of proxyConfig instead:

Proposed fix
-if (import.meta.server && !proxyConfig?.enabled) {
+if (import.meta.server && !proxyConfig) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue` around lines 419 -
428, The condition currently uses proxyConfig?.enabled which no longer exists;
update the server-side check in ScriptGoogleMaps.vue so the link is only added
when no proxyConfig is provided (e.g., keep the import.meta.server check but
replace the !proxyConfig?.enabled test with a presence check like !proxyConfig
or proxyConfig == null) so useHead is called only when the proxy is absent; edit
the block around useHead (the import.meta.server guard and its link entry) to
reference proxyConfig presence instead of proxyConfig?.enabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue`:
- Line 459: The condition that determines whether to include the API key is
using proxyConfig?.enabled which no longer exists and causes apiKey to always be
exposed; update the check in the object where key: proxyConfig?.enabled ?
undefined : apiKey to instead test for the presence of proxyConfig (e.g., key:
proxyConfig ? undefined : apiKey) so when a proxy configuration object exists
the client-side URL omits apiKey; locate this change in ScriptGoogleMaps.vue
around the object that sets key and replace the condition accordingly.
- Around line 419-428: The condition currently uses proxyConfig?.enabled which
no longer exists; update the server-side check in ScriptGoogleMaps.vue so the
link is only added when no proxyConfig is provided (e.g., keep the
import.meta.server check but replace the !proxyConfig?.enabled test with a
presence check like !proxyConfig or proxyConfig == null) so useHead is called
only when the proxy is absent; edit the block around useHead (the
import.meta.server guard and its link entry) to reference proxyConfig presence
instead of proxyConfig?.enabled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39676e23-e4d5-4ecc-8346-8fa3797c62e4

📥 Commits

Reviewing files that changed from the base of the PR and between 2a38fa4 and ce48b26.

📒 Files selected for processing (3)
  • src/module.ts
  • src/runtime/components/GoogleMaps/ScriptGoogleMaps.vue
  • src/runtime/server/google-static-maps-proxy.ts
💤 Files with no reviewable changes (1)
  • src/runtime/server/google-static-maps-proxy.ts

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