input
input copied to clipboard
Experimental Native Embedding Feature has strange VITE_APP_URL var value
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_URL
s 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.
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 :)
Hello. I have the same issue. It would be great to be able to embed the form in a page like this!
@f0sh @anarion80 i changed the way the embed works and it it fixed now in #167