🐛 Improve parse runtime env reading function
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@typebot.io/js",
|
||||
"version": "0.1.18",
|
||||
"version": "0.1.19",
|
||||
"description": "Javascript library to display typebots on your website",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
||||
@@ -4,11 +4,11 @@ import type { ScriptToExecute } from '@typebot.io/schemas'
|
||||
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
|
||||
|
||||
export const executeScript = async ({ content, args }: ScriptToExecute) => {
|
||||
const func = AsyncFunction(
|
||||
...args.map((arg) => arg.id),
|
||||
parseContent(content)
|
||||
)
|
||||
try {
|
||||
const func = AsyncFunction(
|
||||
...args.map((arg) => arg.id),
|
||||
parseContent(content)
|
||||
)
|
||||
await func(...args.map((arg) => arg.value))
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { env } from '@typebot.io/env'
|
||||
import { getRuntimeVariable } from '@typebot.io/env/getRuntimeVariable'
|
||||
|
||||
const cloudViewerUrl = 'https://viewer.typebot.io'
|
||||
|
||||
export const guessApiHost = () =>
|
||||
env.NEXT_PUBLIC_VIEWER_INTERNAL_URL ??
|
||||
env.NEXT_PUBLIC_VIEWER_URL[0] ??
|
||||
getRuntimeVariable('NEXT_PUBLIC_VIEWER_INTERNAL_URL') ??
|
||||
getRuntimeVariable('NEXT_PUBLIC_VIEWER_URL')?.split(',')[0] ??
|
||||
cloudViewerUrl
|
||||
|
||||
Reference in New Issue
Block a user