input icon indicating copy to clipboard operation
input copied to clipboard

Experimental Native Embedding Feature has strange VITE_APP_URL var value

Open f0sh opened this issue 11 months ago • 2 comments

I was trying to setup the new experimental feature to natively embed a form. I implemented the script according to the input output:

<!-- Place this wherever you want to embed your form -->
<div id="k27X-wrapper" class="ipt" style="height: 520px; width: 100%;">
</div>

<!-- Place this before the closing body tag -->
<script src="https://<tld-domain>/js/classic.js"
  data-form="k27X"
  data-hide-title="false"
  data-autofocus="false"
  data-alignleft="false"
  data-hide-navigation="false" async></script>

At the inserted page the javscript under https://<tld-domain>/js/classic.js is correctly loaded however throws the following error:

classic.js:14  SyntaxError: Unexpected token '<', "<h1>Page N"... is not valid JSON

If I check the logs I see that in classic.js:808 the script triggers a fetch trying to get a file from http://localhost:1313/api/routes. This is of course not possible, as this is my local hugo server for testing.

Following to classic.js:808 I see, that the localhost:1313 is coming from the VITE_APP_URL variable which is not set (as I get a ReferenceError: VITE_APP_URL is not defined), so that automatically the standard value /api/routes is taken which then points to my local environment.

const t = await (await fetch({}.VITE_APP_URL ? {}.VITE_APP_URL + "/api/routes" : "/api/routes")).json();`

I have unfortunately absoluty no knowledge about TypeScript and vite.js, but according to an previous commit in the history the variable used to be MIX_APP_URL and there is an matching one defined in Laravel. So I have the feeling that APP_URLs value is not correctly set to VITE_APP_URL.

The configuration for input has the env APP_URL="https://<tld-domain>" set and the setup runs fine.

f0sh avatar Mar 29 '24 18:03 f0sh

Thanks for reporting. It might be totally possible that I missed updating the configs there. Will have a look into it as soon as possible :)

PhilReinking avatar Apr 02 '24 08:04 PhilReinking

Hello. I have the same issue. It would be great to be able to embed the form in a page like this!

anarion80 avatar May 17 '24 11:05 anarion80

@f0sh @anarion80 i changed the way the embed works and it it fixed now in #167

PhilReinking avatar Aug 24 '24 13:08 PhilReinking