@nuxt/scripts 1.0.0-rc.6 → 1.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +2 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +50 -0
- package/dist/devtools-client/200.html +1 -1
- package/dist/devtools-client/404.html +1 -1
- package/dist/devtools-client/_nuxt/{B7jHEBMT.js → B4uHpJPz.js} +1 -1
- package/dist/devtools-client/_nuxt/{BaiqmiV1.js → BBS9G2Kb.js} +1 -1
- package/dist/devtools-client/_nuxt/{qfgRjj7S.js → CQR4zIAm.js} +1 -1
- package/dist/devtools-client/_nuxt/{Chi3DhDl.js → Cxq4HLPL.js} +1 -1
- package/dist/devtools-client/_nuxt/{CLjOeO0G.js → DCBsJT4N.js} +1 -1
- package/dist/devtools-client/_nuxt/{HLYrIHDq.js → DTxy5P8N.js} +18 -18
- package/dist/devtools-client/_nuxt/{BjmZlwuw.js → DvZScWzI.js} +1 -1
- package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
- package/dist/devtools-client/_nuxt/builds/meta/484f72b9-a019-4127-8ab9-c10e92624094.json +1 -0
- package/dist/devtools-client/_nuxt/error-404.d44aGwWI.css +1 -0
- package/dist/devtools-client/_nuxt/error-500.NthMfIEt.css +1 -0
- package/dist/devtools-client/docs/index.html +1 -1
- package/dist/devtools-client/first-party/index.html +1 -1
- package/dist/devtools-client/index.html +1 -1
- package/dist/devtools-client/registry/index.html +1 -1
- package/dist/module.d.mts +51 -2
- package/dist/module.d.ts +51 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +80 -9
- package/dist/registry.mjs +10 -10
- package/dist/runtime/server/bluesky-embed.js +3 -2
- package/dist/runtime/server/google-maps-geocode-proxy.js +4 -3
- package/dist/runtime/server/google-static-maps-proxy.js +4 -3
- package/dist/runtime/server/gravatar-proxy.js +4 -3
- package/dist/runtime/server/instagram-embed.d.ts +1 -16
- package/dist/runtime/server/instagram-embed.js +5 -116
- package/dist/runtime/server/proxy-handler.js +1 -2
- package/dist/runtime/server/utils/image-proxy.js +3 -2
- package/dist/runtime/server/utils/instagram-embed.d.ts +16 -0
- package/dist/runtime/server/utils/instagram-embed.js +152 -0
- package/dist/runtime/server/utils/sign.d.ts +109 -0
- package/dist/runtime/server/utils/sign.js +88 -0
- package/dist/runtime/server/utils/withSigning.d.ts +23 -0
- package/dist/runtime/server/utils/withSigning.js +18 -0
- package/dist/runtime/server/x-embed.js +3 -2
- package/dist/runtime/types.d.ts +9 -1
- package/dist/types.d.mts +2 -2
- package/package.json +6 -2
- package/dist/devtools-client/_nuxt/builds/meta/640f0a39-e659-4a31-8b8d-adbd9af52f1e.json +0 -1
- package/dist/devtools-client/_nuxt/error-404.Dwj0Wlzm.css +0 -1
- package/dist/devtools-client/_nuxt/error-500.B4wHUYBa.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as s,o,c as n,a as l,_ as r,g as a}from"./
|
|
1
|
+
import{f as s,o,c as n,a as l,_ as r,g as a}from"./DTxy5P8N.js";const _={class:"h-full max-h-full overflow-hidden"},u=["src","title"],i=s({__name:"DevtoolsDocs",props:{url:{}},setup(e){return(c,t)=>(o(),n("div",_,[l("iframe",{src:e.url,title:`Documentation - ${e.url}`,class:"w-full h-full border-none",style:{"min-height":"calc(100vh - 100px)"}},null,8,u)]))}}),f=Object.assign(i,{__name:"DevtoolsDocs"}),m={};function d(e,c){const t=f;return o(),a(t,{url:"https://scripts.nuxt.com"})}const p=r(m,[["render",d]]);export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"484f72b9-a019-4127-8ab9-c10e92624094","timestamp":1776136489632}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"484f72b9-a019-4127-8ab9-c10e92624094","timestamp":1776136489632,"prerendered":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.grid[data-v-3ecdecd2]{display:grid}.mb-2[data-v-3ecdecd2]{margin-bottom:.5rem}.mb-4[data-v-3ecdecd2]{margin-bottom:1rem}.max-w-520px[data-v-3ecdecd2]{max-width:520px}.min-h-screen[data-v-3ecdecd2]{min-height:100vh}.w-full[data-v-3ecdecd2]{width:100%}.flex[data-v-3ecdecd2]{display:flex}.place-content-center[data-v-3ecdecd2]{place-content:center}.items-center[data-v-3ecdecd2]{align-items:center}.justify-center[data-v-3ecdecd2]{justify-content:center}.overflow-hidden[data-v-3ecdecd2]{overflow:hidden}.bg-white[data-v-3ecdecd2]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-2[data-v-3ecdecd2]{padding-left:.5rem;padding-right:.5rem}.text-center[data-v-3ecdecd2]{text-align:center}.text-\[80px\][data-v-3ecdecd2]{font-size:80px}.text-2xl[data-v-3ecdecd2]{font-size:1.5rem;line-height:2rem}.text-sm[data-v-3ecdecd2]{font-size:.875rem;line-height:1.25rem}.text-\[\#020420\][data-v-3ecdecd2]{--un-text-opacity:1;color:rgb(2 4 32/var(--un-text-opacity))}.text-\[\#64748B\][data-v-3ecdecd2]{--un-text-opacity:1;color:rgb(100 116 139/var(--un-text-opacity))}.hover\:text-\[\#00DC82\][data-v-3ecdecd2]:hover{--un-text-opacity:1;color:rgb(0 220 130/var(--un-text-opacity))}.font-medium[data-v-3ecdecd2]{font-weight:500}.font-semibold[data-v-3ecdecd2]{font-weight:600}.leading-none[data-v-3ecdecd2]{line-height:1}.tracking-wide[data-v-3ecdecd2]{letter-spacing:.025em}.font-sans[data-v-3ecdecd2]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.tabular-nums[data-v-3ecdecd2]{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)}.underline[data-v-3ecdecd2]{text-decoration-line:underline}.underline-offset-3[data-v-3ecdecd2]{text-underline-offset:3px}.antialiased[data-v-3ecdecd2]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media(prefers-color-scheme:dark){.dark\:bg-\[\#020420\][data-v-3ecdecd2]{--un-bg-opacity:1;background-color:rgb(2 4 32/var(--un-bg-opacity))}.dark\:text-white[data-v-3ecdecd2]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media(min-width:640px){.sm\:text-\[110px\][data-v-3ecdecd2]{font-size:110px}.sm\:text-3xl[data-v-3ecdecd2]{font-size:1.875rem;line-height:2.25rem}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.grid[data-v-10ed44ef]{display:grid}.mb-2[data-v-10ed44ef]{margin-bottom:.5rem}.mb-4[data-v-10ed44ef]{margin-bottom:1rem}.max-w-520px[data-v-10ed44ef]{max-width:520px}.min-h-screen[data-v-10ed44ef]{min-height:100vh}.place-content-center[data-v-10ed44ef]{place-content:center}.overflow-hidden[data-v-10ed44ef]{overflow:hidden}.bg-white[data-v-10ed44ef]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-2[data-v-10ed44ef]{padding-left:.5rem;padding-right:.5rem}.text-center[data-v-10ed44ef]{text-align:center}.text-\[80px\][data-v-10ed44ef]{font-size:80px}.text-2xl[data-v-10ed44ef]{font-size:1.5rem;line-height:2rem}.text-\[\#020420\][data-v-10ed44ef]{--un-text-opacity:1;color:rgb(2 4 32/var(--un-text-opacity))}.text-\[\#64748B\][data-v-10ed44ef]{--un-text-opacity:1;color:rgb(100 116 139/var(--un-text-opacity))}.font-semibold[data-v-10ed44ef]{font-weight:600}.leading-none[data-v-10ed44ef]{line-height:1}.tracking-wide[data-v-10ed44ef]{letter-spacing:.025em}.font-sans[data-v-10ed44ef]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.tabular-nums[data-v-10ed44ef]{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)}.antialiased[data-v-10ed44ef]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media(prefers-color-scheme:dark){.dark\:bg-\[\#020420\][data-v-10ed44ef]{--un-bg-opacity:1;background-color:rgb(2 4 32/var(--un-bg-opacity))}.dark\:text-white[data-v-10ed44ef]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media(min-width:640px){.sm\:text-\[110px\][data-v-10ed44ef]{font-size:110px}.sm\:text-3xl[data-v-10ed44ef]{font-size:1.875rem;line-height:2.25rem}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DTxy5P8N.js"><script type="module" src="/__nuxt-scripts/_nuxt/DTxy5P8N.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"484f72b9-a019-4127-8ab9-c10e92624094",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1776136498552,false]</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DTxy5P8N.js"><script type="module" src="/__nuxt-scripts/_nuxt/DTxy5P8N.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"484f72b9-a019-4127-8ab9-c10e92624094",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1776136498553,false]</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DTxy5P8N.js"><script type="module" src="/__nuxt-scripts/_nuxt/DTxy5P8N.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"484f72b9-a019-4127-8ab9-c10e92624094",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1776136498554,false]</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-scripts/_nuxt/entry.BwpOBArY.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-scripts/_nuxt/DTxy5P8N.js"><script type="module" src="/__nuxt-scripts/_nuxt/DTxy5P8N.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-scripts",buildId:"484f72b9-a019-4127-8ab9-c10e92624094",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1776136498554,false]</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -3,6 +3,23 @@ import { FetchOptions } from 'ofetch';
|
|
|
3
3
|
import { RegistryScripts, FirstPartyPrivacy, NuxtConfigScriptRegistry, NuxtUseScriptOptionsSerializable, NuxtUseScriptInput, ResolvedProxyAutoInject } from '../dist/runtime/types.js';
|
|
4
4
|
export { FirstPartyPrivacy } from '../dist/runtime/types.js';
|
|
5
5
|
|
|
6
|
+
interface ResolvedProxySecret {
|
|
7
|
+
secret: string;
|
|
8
|
+
/** True when the secret exists only in memory (dev-only fallback; won't survive restarts). */
|
|
9
|
+
ephemeral: boolean;
|
|
10
|
+
/** Where the secret came from, for logging. */
|
|
11
|
+
source: 'config' | 'env' | 'dotenv-generated' | 'memory-generated';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the HMAC signing secret used for proxy URL signing.
|
|
15
|
+
*
|
|
16
|
+
* Precedence:
|
|
17
|
+
* 1. `scripts.security.secret` in nuxt.config
|
|
18
|
+
* 2. `NUXT_SCRIPTS_PROXY_SECRET` env var
|
|
19
|
+
* 3. Dev-only auto-generation: write to `.env` (or keep in memory as last resort)
|
|
20
|
+
* 4. Empty string (prod without secret; caller decides whether this is fatal)
|
|
21
|
+
*/
|
|
22
|
+
declare function resolveProxySecret(rootDir: string, isDev: boolean, configSecret?: string, autoGenerate?: boolean): ResolvedProxySecret | undefined;
|
|
6
23
|
declare function isProxyDisabled(registryKey: string, registry?: NuxtConfigScriptRegistry, runtimeConfig?: Record<string, any>): boolean;
|
|
7
24
|
declare function applyAutoInject(registry: NuxtConfigScriptRegistry, runtimeConfig: Record<string, any>, proxyPrefix: string, registryKey: string, autoInject: ResolvedProxyAutoInject): void;
|
|
8
25
|
interface ModuleOptions {
|
|
@@ -72,6 +89,38 @@ interface ModuleOptions {
|
|
|
72
89
|
*/
|
|
73
90
|
integrity?: boolean | 'sha256' | 'sha384' | 'sha512';
|
|
74
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Proxy endpoint security.
|
|
94
|
+
*
|
|
95
|
+
* Several proxy endpoints (Google Static Maps, Geocode, Gravatar, embed image proxies)
|
|
96
|
+
* inject server-side API keys or forward requests to third-party services. Without
|
|
97
|
+
* signing, these are open to cost/quota abuse. Enable signing to require that only
|
|
98
|
+
* URLs generated server-side (during SSR/prerender, or via `/_scripts/sign`) are
|
|
99
|
+
* accepted.
|
|
100
|
+
*
|
|
101
|
+
* The secret must be deterministic across deployments so that prerendered URLs
|
|
102
|
+
* remain valid. Set it via `NUXT_SCRIPTS_PROXY_SECRET` or `security.secret`.
|
|
103
|
+
*/
|
|
104
|
+
security?: {
|
|
105
|
+
/**
|
|
106
|
+
* HMAC secret used to sign proxy URLs.
|
|
107
|
+
*
|
|
108
|
+
* Falls back to `process.env.NUXT_SCRIPTS_PROXY_SECRET` if unset. In dev,
|
|
109
|
+
* the module auto-generates a secret into your `.env` file when neither is
|
|
110
|
+
* provided (disable via `autoGenerateSecret: false`). In production, a
|
|
111
|
+
* missing secret logs a warning; proxy endpoints remain functional but unprotected.
|
|
112
|
+
*
|
|
113
|
+
* Generate one with: `npx @nuxt/scripts generate-secret`
|
|
114
|
+
*/
|
|
115
|
+
secret?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Automatically generate and persist a signing secret to `.env` when running
|
|
118
|
+
* `nuxt dev` without one configured.
|
|
119
|
+
*
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
autoGenerateSecret?: boolean;
|
|
123
|
+
};
|
|
75
124
|
/**
|
|
76
125
|
* Google Static Maps proxy configuration.
|
|
77
126
|
* Proxies static map images through your server to fix CORS issues and enable caching.
|
|
@@ -117,5 +166,5 @@ interface ModuleHooks {
|
|
|
117
166
|
}
|
|
118
167
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
119
168
|
|
|
120
|
-
export { applyAutoInject, _default as default, isProxyDisabled };
|
|
121
|
-
export type { ModuleHooks, ModuleOptions };
|
|
169
|
+
export { applyAutoInject, _default as default, isProxyDisabled, resolveProxySecret };
|
|
170
|
+
export type { ModuleHooks, ModuleOptions, ResolvedProxySecret };
|
package/dist/module.d.ts
CHANGED
|
@@ -3,6 +3,23 @@ import { FetchOptions } from 'ofetch';
|
|
|
3
3
|
import { RegistryScripts, FirstPartyPrivacy, NuxtConfigScriptRegistry, NuxtUseScriptOptionsSerializable, NuxtUseScriptInput, ResolvedProxyAutoInject } from '../dist/runtime/types.js';
|
|
4
4
|
export { FirstPartyPrivacy } from '../dist/runtime/types.js';
|
|
5
5
|
|
|
6
|
+
interface ResolvedProxySecret {
|
|
7
|
+
secret: string;
|
|
8
|
+
/** True when the secret exists only in memory (dev-only fallback; won't survive restarts). */
|
|
9
|
+
ephemeral: boolean;
|
|
10
|
+
/** Where the secret came from, for logging. */
|
|
11
|
+
source: 'config' | 'env' | 'dotenv-generated' | 'memory-generated';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the HMAC signing secret used for proxy URL signing.
|
|
15
|
+
*
|
|
16
|
+
* Precedence:
|
|
17
|
+
* 1. `scripts.security.secret` in nuxt.config
|
|
18
|
+
* 2. `NUXT_SCRIPTS_PROXY_SECRET` env var
|
|
19
|
+
* 3. Dev-only auto-generation: write to `.env` (or keep in memory as last resort)
|
|
20
|
+
* 4. Empty string (prod without secret; caller decides whether this is fatal)
|
|
21
|
+
*/
|
|
22
|
+
declare function resolveProxySecret(rootDir: string, isDev: boolean, configSecret?: string, autoGenerate?: boolean): ResolvedProxySecret | undefined;
|
|
6
23
|
declare function isProxyDisabled(registryKey: string, registry?: NuxtConfigScriptRegistry, runtimeConfig?: Record<string, any>): boolean;
|
|
7
24
|
declare function applyAutoInject(registry: NuxtConfigScriptRegistry, runtimeConfig: Record<string, any>, proxyPrefix: string, registryKey: string, autoInject: ResolvedProxyAutoInject): void;
|
|
8
25
|
interface ModuleOptions {
|
|
@@ -72,6 +89,38 @@ interface ModuleOptions {
|
|
|
72
89
|
*/
|
|
73
90
|
integrity?: boolean | 'sha256' | 'sha384' | 'sha512';
|
|
74
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Proxy endpoint security.
|
|
94
|
+
*
|
|
95
|
+
* Several proxy endpoints (Google Static Maps, Geocode, Gravatar, embed image proxies)
|
|
96
|
+
* inject server-side API keys or forward requests to third-party services. Without
|
|
97
|
+
* signing, these are open to cost/quota abuse. Enable signing to require that only
|
|
98
|
+
* URLs generated server-side (during SSR/prerender, or via `/_scripts/sign`) are
|
|
99
|
+
* accepted.
|
|
100
|
+
*
|
|
101
|
+
* The secret must be deterministic across deployments so that prerendered URLs
|
|
102
|
+
* remain valid. Set it via `NUXT_SCRIPTS_PROXY_SECRET` or `security.secret`.
|
|
103
|
+
*/
|
|
104
|
+
security?: {
|
|
105
|
+
/**
|
|
106
|
+
* HMAC secret used to sign proxy URLs.
|
|
107
|
+
*
|
|
108
|
+
* Falls back to `process.env.NUXT_SCRIPTS_PROXY_SECRET` if unset. In dev,
|
|
109
|
+
* the module auto-generates a secret into your `.env` file when neither is
|
|
110
|
+
* provided (disable via `autoGenerateSecret: false`). In production, a
|
|
111
|
+
* missing secret logs a warning; proxy endpoints remain functional but unprotected.
|
|
112
|
+
*
|
|
113
|
+
* Generate one with: `npx @nuxt/scripts generate-secret`
|
|
114
|
+
*/
|
|
115
|
+
secret?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Automatically generate and persist a signing secret to `.env` when running
|
|
118
|
+
* `nuxt dev` without one configured.
|
|
119
|
+
*
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
autoGenerateSecret?: boolean;
|
|
123
|
+
};
|
|
75
124
|
/**
|
|
76
125
|
* Google Static Maps proxy configuration.
|
|
77
126
|
* Proxies static map images through your server to fix CORS issues and enable caching.
|
|
@@ -117,5 +166,5 @@ interface ModuleHooks {
|
|
|
117
166
|
}
|
|
118
167
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
119
168
|
|
|
120
|
-
export { applyAutoInject, _default as default, isProxyDisabled };
|
|
121
|
-
export type { ModuleHooks, ModuleOptions };
|
|
169
|
+
export { applyAutoInject, _default as default, isProxyDisabled, resolveProxySecret };
|
|
170
|
+
export type { ModuleHooks, ModuleOptions, ResolvedProxySecret };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync, appendFileSync, writeFileSync, readdirSync } from 'node:fs';
|
|
2
3
|
import { useNuxt, addDevServerHandler, extendRouteRules, tryUseNuxt, createResolver, extendViteConfig, logger as logger$1, useLogger, addTypeTemplate, defineNuxtModule, addPluginTemplate, addServerHandler, addImports, addComponentsDir, addTemplate, hasNuxtModule, addBuildPlugin } from '@nuxt/kit';
|
|
3
4
|
import { defu } from 'defu';
|
|
4
5
|
import { join, resolve } from 'pathe';
|
|
@@ -12,7 +13,6 @@ import { isCI, provider } from 'std-env';
|
|
|
12
13
|
import { parseAndWalk, ScopeTracker, walk, ScopeTrackerFunction, ScopeTrackerIdentifier, ScopeTrackerFunctionParam, ScopeTrackerVariable } from 'oxc-walker';
|
|
13
14
|
import { createUnplugin } from 'unplugin';
|
|
14
15
|
import { pathToFileURL } from 'node:url';
|
|
15
|
-
import { createHash } from 'node:crypto';
|
|
16
16
|
import fsp from 'node:fs/promises';
|
|
17
17
|
import { colors } from 'consola/utils';
|
|
18
18
|
import MagicString from 'magic-string';
|
|
@@ -1373,6 +1373,42 @@ function fixSelfClosingScriptComponents(nuxt) {
|
|
|
1373
1373
|
}
|
|
1374
1374
|
const UPPER_RE = /([A-Z])/g;
|
|
1375
1375
|
const toScreamingSnake = (s) => s.replace(UPPER_RE, "_$1").toUpperCase();
|
|
1376
|
+
const PROXY_SECRET_ENV_KEY = "NUXT_SCRIPTS_PROXY_SECRET";
|
|
1377
|
+
const PROXY_SECRET_ENV_LINE_RE = /^NUXT_SCRIPTS_PROXY_SECRET=/m;
|
|
1378
|
+
const PROXY_SECRET_ENV_VALUE_RE = /^NUXT_SCRIPTS_PROXY_SECRET=(.+)$/m;
|
|
1379
|
+
function resolveProxySecret(rootDir, isDev, configSecret, autoGenerate = true) {
|
|
1380
|
+
if (configSecret)
|
|
1381
|
+
return { secret: configSecret, ephemeral: false, source: "config" };
|
|
1382
|
+
const envSecret = process.env[PROXY_SECRET_ENV_KEY];
|
|
1383
|
+
if (envSecret)
|
|
1384
|
+
return { secret: envSecret, ephemeral: false, source: "env" };
|
|
1385
|
+
if (!isDev || !autoGenerate)
|
|
1386
|
+
return void 0;
|
|
1387
|
+
const secret = randomBytes(32).toString("hex");
|
|
1388
|
+
const envPath = resolve(rootDir, ".env");
|
|
1389
|
+
const line = `${PROXY_SECRET_ENV_KEY}=${secret}
|
|
1390
|
+
`;
|
|
1391
|
+
try {
|
|
1392
|
+
if (existsSync(envPath)) {
|
|
1393
|
+
const contents = readFileSync(envPath, "utf-8");
|
|
1394
|
+
if (PROXY_SECRET_ENV_LINE_RE.test(contents)) {
|
|
1395
|
+
const match = contents.match(PROXY_SECRET_ENV_VALUE_RE);
|
|
1396
|
+
if (match?.[1])
|
|
1397
|
+
return { secret: match[1].trim(), ephemeral: false, source: "dotenv-generated" };
|
|
1398
|
+
}
|
|
1399
|
+
appendFileSync(envPath, contents.endsWith("\n") ? line : `
|
|
1400
|
+
${line}`);
|
|
1401
|
+
} else {
|
|
1402
|
+
writeFileSync(envPath, `# Generated by @nuxt/scripts
|
|
1403
|
+
${line}`);
|
|
1404
|
+
}
|
|
1405
|
+
process.env[PROXY_SECRET_ENV_KEY] = secret;
|
|
1406
|
+
return { secret, ephemeral: false, source: "dotenv-generated" };
|
|
1407
|
+
} catch {
|
|
1408
|
+
process.env[PROXY_SECRET_ENV_KEY] = secret;
|
|
1409
|
+
return { secret, ephemeral: true, source: "memory-generated" };
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1376
1412
|
function isProxyDisabled(registryKey, registry2, runtimeConfig) {
|
|
1377
1413
|
const entry = registry2?.[registryKey];
|
|
1378
1414
|
if (!entry)
|
|
@@ -1684,12 +1720,12 @@ They will load directly from third-party servers.`
|
|
|
1684
1720
|
if (totalDomains > 0 && nuxt.options.dev) {
|
|
1685
1721
|
logger.success(`Proxy mode enabled for ${registryKeys.length} script(s), ${totalDomains} domain(s) proxied (privacy: ${privacyLabel})`);
|
|
1686
1722
|
}
|
|
1687
|
-
const
|
|
1688
|
-
const
|
|
1689
|
-
if (
|
|
1723
|
+
const proxyStaticPresets = ["static", "github-pages", "cloudflare-pages-static", "netlify-static", "azure-static", "firebase-static"];
|
|
1724
|
+
const proxyPreset = process.env.NITRO_PRESET || "";
|
|
1725
|
+
if (proxyStaticPresets.includes(proxyPreset)) {
|
|
1690
1726
|
logger.warn(
|
|
1691
|
-
`Proxy collection endpoints require a server runtime (detected: ${
|
|
1692
|
-
Scripts will be bundled, but collection requests will not be proxied.
|
|
1727
|
+
`Proxy collection endpoints require a server runtime (detected: ${proxyPreset || "static"}).
|
|
1728
|
+
Scripts will be bundled, but collection requests will not be proxied and URL signing will be unavailable.
|
|
1693
1729
|
Options: configure platform rewrites, switch to server-rendered mode, or disable with proxy: false.`
|
|
1694
1730
|
);
|
|
1695
1731
|
}
|
|
@@ -1736,6 +1772,7 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
|
|
|
1736
1772
|
});
|
|
1737
1773
|
const scriptsPrefix = config.prefix || "/_scripts";
|
|
1738
1774
|
const enabledEndpoints = {};
|
|
1775
|
+
let anyHandlerRequiresSigning = false;
|
|
1739
1776
|
for (const script of scripts) {
|
|
1740
1777
|
if (!script.serverHandlers?.length || !script.registryKey)
|
|
1741
1778
|
continue;
|
|
@@ -1744,11 +1781,14 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
|
|
|
1744
1781
|
continue;
|
|
1745
1782
|
enabledEndpoints[script.registryKey] = true;
|
|
1746
1783
|
for (const handler of script.serverHandlers) {
|
|
1784
|
+
const resolvedRoute = handler.route.replace("/_scripts", scriptsPrefix);
|
|
1747
1785
|
addServerHandler({
|
|
1748
|
-
route:
|
|
1786
|
+
route: resolvedRoute,
|
|
1749
1787
|
handler: handler.handler,
|
|
1750
1788
|
middleware: handler.middleware
|
|
1751
1789
|
});
|
|
1790
|
+
if (handler.requiresSigning)
|
|
1791
|
+
anyHandlerRequiresSigning = true;
|
|
1752
1792
|
}
|
|
1753
1793
|
if (script.registryKey === "gravatar") {
|
|
1754
1794
|
const gravatarConfig = config.registry?.gravatar?.[0] || {};
|
|
@@ -1768,7 +1808,38 @@ Options: configure platform rewrites, switch to server-rendered mode, or disable
|
|
|
1768
1808
|
{ endpoints: enabledEndpoints },
|
|
1769
1809
|
nuxt.options.runtimeConfig.public["nuxt-scripts"]
|
|
1770
1810
|
);
|
|
1811
|
+
const staticPresets = ["static", "github-pages", "cloudflare-pages-static", "netlify-static", "azure-static", "firebase-static"];
|
|
1812
|
+
const nitroPreset = process.env.NITRO_PRESET || "";
|
|
1813
|
+
const isStaticTarget = staticPresets.includes(nitroPreset);
|
|
1814
|
+
const isSpa = nuxt.options.ssr === false;
|
|
1815
|
+
if (anyHandlerRequiresSigning && (isSpa || isStaticTarget)) {
|
|
1816
|
+
logger.warn(
|
|
1817
|
+
`[security] URL signing requires a server runtime${isStaticTarget ? ` (detected preset: ${nitroPreset})` : " (ssr: false)"}.
|
|
1818
|
+
Proxy endpoints will work without signature verification.
|
|
1819
|
+
To enable signing, deploy with a server-rendered target or configure platform-level rewrites.`
|
|
1820
|
+
);
|
|
1821
|
+
} else if (anyHandlerRequiresSigning) {
|
|
1822
|
+
const proxySecretResolved = resolveProxySecret(
|
|
1823
|
+
nuxt.options.rootDir,
|
|
1824
|
+
!!nuxt.options.dev,
|
|
1825
|
+
config.security?.secret,
|
|
1826
|
+
config.security?.autoGenerateSecret !== false
|
|
1827
|
+
);
|
|
1828
|
+
if (proxySecretResolved?.source === "dotenv-generated")
|
|
1829
|
+
logger.info(`[security] Generated ${PROXY_SECRET_ENV_KEY} in .env for signed proxy URLs.`);
|
|
1830
|
+
else if (proxySecretResolved?.source === "memory-generated")
|
|
1831
|
+
logger.warn(`[security] Generated an in-memory ${PROXY_SECRET_ENV_KEY} (could not write .env). Signed URLs will break across restarts.`);
|
|
1832
|
+
if (proxySecretResolved?.secret) {
|
|
1833
|
+
nuxt.options.runtimeConfig["nuxt-scripts"].proxySecret = proxySecretResolved.secret;
|
|
1834
|
+
} else if (!nuxt.options.dev) {
|
|
1835
|
+
logger.warn(
|
|
1836
|
+
`[security] ${PROXY_SECRET_ENV_KEY} is not set. Proxy endpoints will pass requests through without signature verification.
|
|
1837
|
+
Generate one with: npx @nuxt/scripts generate-secret
|
|
1838
|
+
Then set the env var: ${PROXY_SECRET_ENV_KEY}=<secret>`
|
|
1839
|
+
);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1771
1842
|
}
|
|
1772
1843
|
});
|
|
1773
1844
|
|
|
1774
|
-
export { applyAutoInject, module$1 as default, isProxyDisabled };
|
|
1845
|
+
export { applyAutoInject, module$1 as default, isProxyDisabled, resolveProxySecret };
|
package/dist/registry.mjs
CHANGED
|
@@ -554,8 +554,8 @@ async function registry(resolve) {
|
|
|
554
554
|
envDefaults: { apiKey: "" },
|
|
555
555
|
category: "content",
|
|
556
556
|
serverHandlers: [
|
|
557
|
-
{ route: "/_scripts/proxy/google-static-maps", handler: "./runtime/server/google-static-maps-proxy" },
|
|
558
|
-
{ route: "/_scripts/proxy/google-maps-geocode", handler: "./runtime/server/google-maps-geocode-proxy" }
|
|
557
|
+
{ route: "/_scripts/proxy/google-static-maps", handler: "./runtime/server/google-static-maps-proxy", requiresSigning: true },
|
|
558
|
+
{ route: "/_scripts/proxy/google-maps-geocode", handler: "./runtime/server/google-maps-geocode-proxy", requiresSigning: true }
|
|
559
559
|
]
|
|
560
560
|
}),
|
|
561
561
|
def("blueskyEmbed", {
|
|
@@ -564,8 +564,8 @@ async function registry(resolve) {
|
|
|
564
564
|
label: "Bluesky Embed",
|
|
565
565
|
category: "content",
|
|
566
566
|
serverHandlers: [
|
|
567
|
-
{ route: "/_scripts/embed/bluesky", handler: "./runtime/server/bluesky-embed" },
|
|
568
|
-
{ route: "/_scripts/embed/bluesky-image", handler: "./runtime/server/bluesky-embed-image" }
|
|
567
|
+
{ route: "/_scripts/embed/bluesky", handler: "./runtime/server/bluesky-embed", requiresSigning: true },
|
|
568
|
+
{ route: "/_scripts/embed/bluesky-image", handler: "./runtime/server/bluesky-embed-image", requiresSigning: true }
|
|
569
569
|
]
|
|
570
570
|
}),
|
|
571
571
|
def("instagramEmbed", {
|
|
@@ -574,9 +574,9 @@ async function registry(resolve) {
|
|
|
574
574
|
label: "Instagram Embed",
|
|
575
575
|
category: "content",
|
|
576
576
|
serverHandlers: [
|
|
577
|
-
{ route: "/_scripts/embed/instagram", handler: "./runtime/server/instagram-embed" },
|
|
578
|
-
{ route: "/_scripts/embed/instagram-image", handler: "./runtime/server/instagram-embed-image" },
|
|
579
|
-
{ route: "/_scripts/embed/instagram-asset", handler: "./runtime/server/instagram-embed-asset" }
|
|
577
|
+
{ route: "/_scripts/embed/instagram", handler: "./runtime/server/instagram-embed", requiresSigning: true },
|
|
578
|
+
{ route: "/_scripts/embed/instagram-image", handler: "./runtime/server/instagram-embed-image", requiresSigning: true },
|
|
579
|
+
{ route: "/_scripts/embed/instagram-asset", handler: "./runtime/server/instagram-embed-asset", requiresSigning: true }
|
|
580
580
|
]
|
|
581
581
|
}),
|
|
582
582
|
def("xEmbed", {
|
|
@@ -585,8 +585,8 @@ async function registry(resolve) {
|
|
|
585
585
|
label: "X Embed",
|
|
586
586
|
category: "content",
|
|
587
587
|
serverHandlers: [
|
|
588
|
-
{ route: "/_scripts/embed/x", handler: "./runtime/server/x-embed" },
|
|
589
|
-
{ route: "/_scripts/embed/x-image", handler: "./runtime/server/x-embed-image" }
|
|
588
|
+
{ route: "/_scripts/embed/x", handler: "./runtime/server/x-embed", requiresSigning: true },
|
|
589
|
+
{ route: "/_scripts/embed/x-image", handler: "./runtime/server/x-embed-image", requiresSigning: true }
|
|
590
590
|
]
|
|
591
591
|
}),
|
|
592
592
|
// support
|
|
@@ -690,7 +690,7 @@ async function registry(resolve) {
|
|
|
690
690
|
privacy: PRIVACY_IP_ONLY
|
|
691
691
|
},
|
|
692
692
|
serverHandlers: [
|
|
693
|
-
{ route: "/_scripts/proxy/gravatar", handler: "./runtime/server/gravatar-proxy" }
|
|
693
|
+
{ route: "/_scripts/proxy/gravatar", handler: "./runtime/server/gravatar-proxy", requiresSigning: true }
|
|
694
694
|
]
|
|
695
695
|
})
|
|
696
696
|
]);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
2
|
import { $fetch } from "ofetch";
|
|
3
|
+
import { withSigning } from "./utils/withSigning.js";
|
|
3
4
|
const BSKY_POST_URL_RE = /^https:\/\/bsky\.app\/profile\/([^/]+)\/post\/([^/?]+)$/;
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
+
export default withSigning(defineEventHandler(async (event) => {
|
|
5
6
|
const query = getQuery(event);
|
|
6
7
|
const postUrl = query.url;
|
|
7
8
|
if (!postUrl) {
|
|
@@ -56,4 +57,4 @@ export default defineEventHandler(async (event) => {
|
|
|
56
57
|
setHeader(event, "Content-Type", "application/json");
|
|
57
58
|
setHeader(event, "Cache-Control", "public, max-age=600, s-maxage=600");
|
|
58
59
|
return post;
|
|
59
|
-
});
|
|
60
|
+
}));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#imports";
|
|
2
1
|
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
3
|
import { $fetch } from "ofetch";
|
|
4
4
|
import { withQuery } from "ufo";
|
|
5
|
-
|
|
5
|
+
import { withSigning } from "./utils/withSigning.js";
|
|
6
|
+
export default withSigning(defineEventHandler(async (event) => {
|
|
6
7
|
const runtimeConfig = useRuntimeConfig();
|
|
7
8
|
const privateConfig = runtimeConfig["nuxt-scripts"]?.googleMapsGeocodeProxy;
|
|
8
9
|
const apiKey = privateConfig?.apiKey;
|
|
@@ -31,4 +32,4 @@ export default defineEventHandler(async (event) => {
|
|
|
31
32
|
setHeader(event, "Content-Type", "application/json");
|
|
32
33
|
setHeader(event, "Cache-Control", "public, max-age=86400, s-maxage=86400");
|
|
33
34
|
return data;
|
|
34
|
-
});
|
|
35
|
+
}));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#imports";
|
|
2
1
|
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
3
|
import { $fetch } from "ofetch";
|
|
4
4
|
import { withQuery } from "ufo";
|
|
5
|
-
|
|
5
|
+
import { withSigning } from "./utils/withSigning.js";
|
|
6
|
+
export default withSigning(defineEventHandler(async (event) => {
|
|
6
7
|
const runtimeConfig = useRuntimeConfig();
|
|
7
8
|
const publicConfig = runtimeConfig.public["nuxt-scripts"]?.googleStaticMapsProxy;
|
|
8
9
|
const privateConfig = runtimeConfig["nuxt-scripts"]?.googleStaticMapsProxy;
|
|
@@ -40,4 +41,4 @@ export default defineEventHandler(async (event) => {
|
|
|
40
41
|
setHeader(event, "Cache-Control", `public, max-age=${cacheMaxAge}, s-maxage=${cacheMaxAge}`);
|
|
41
42
|
setHeader(event, "Vary", "Accept-Encoding");
|
|
42
43
|
return response._data;
|
|
43
|
-
});
|
|
44
|
+
}));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#imports";
|
|
2
1
|
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
3
|
import { $fetch } from "ofetch";
|
|
4
4
|
import { withQuery } from "ufo";
|
|
5
|
-
|
|
5
|
+
import { withSigning } from "./utils/withSigning.js";
|
|
6
|
+
export default withSigning(defineEventHandler(async (event) => {
|
|
6
7
|
const runtimeConfig = useRuntimeConfig();
|
|
7
8
|
const proxyConfig = runtimeConfig.public["nuxt-scripts"]?.gravatarProxy;
|
|
8
9
|
const query = getQuery(event);
|
|
@@ -43,4 +44,4 @@ export default defineEventHandler(async (event) => {
|
|
|
43
44
|
setHeader(event, "Cache-Control", `public, max-age=${cacheMaxAge}, s-maxage=${cacheMaxAge}`);
|
|
44
45
|
setHeader(event, "Vary", "Accept-Encoding");
|
|
45
46
|
return response._data;
|
|
46
|
-
});
|
|
47
|
+
}));
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const AMP_RE: RegExp;
|
|
3
|
-
export declare const SCONTENT_RE: RegExp;
|
|
4
|
-
export declare const STATIC_CDN_RE: RegExp;
|
|
5
|
-
export declare const LOOKASIDE_RE: RegExp;
|
|
6
|
-
export declare const INSTAGRAM_IMAGE_HOSTS: string[];
|
|
7
|
-
export declare const INSTAGRAM_ASSET_HOST = "static.cdninstagram.com";
|
|
8
|
-
export declare function proxyImageUrl(url: string, prefix?: string): string;
|
|
9
|
-
export declare function proxyAssetUrl(url: string, prefix?: string): string;
|
|
10
|
-
export declare function rewriteUrl(url: string, prefix?: string): string;
|
|
11
|
-
export declare function rewriteUrlsInText(text: string, prefix?: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Scope CSS rules under a parent selector and strip global/page-level rules.
|
|
14
|
-
* Removes :root, html, body selectors and @charset/@import at-rules.
|
|
15
|
-
*/
|
|
16
|
-
export declare function scopeCss(css: string, scopeSelector: string): string;
|
|
1
|
+
export { proxyAssetUrl, proxyImageUrl, rewriteUrl, rewriteUrlsInText, scopeCss } from './utils/instagram-embed.js';
|
|
17
2
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string>>;
|
|
18
3
|
export default _default;
|