summaryrefslogtreecommitdiff
path: root/packages/integrations/cloudflare/src/util.ts
blob: 120cb73343fa4207ed033c2b9b71485d8547de0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export const isNode =
	typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]';

export function getProcessEnvProxy() {
	return new Proxy(
		{},
		{
			get: (target, prop) => {
				console.warn(
					// NOTE: \0 prevents Vite replacement
					`Unable to access \`import.meta\0.env.${prop.toString()}\` on initialization ` +
						`as the Cloudflare platform only provides the environment variables per request. ` +
						`Please move the environment variable access inside a function ` +
						`that's only called after a request has been received.`
				);
			},
		}
	);
}