-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set_profile & CORS #391
Comments
Hi, Can you please add the browser's DevTools logs or a screenshot? |
Thank you for the quick reply. Index.html loads but is blank: If I right-click and inspect the JS console, I see: And here is index.html: (NOTE: I have to put the <!doctype html>
<html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.png" />
<link rel="modulepreload" href="/_app/immutable/entry/start.mFb7rvTb.js">
<link rel="modulepreload" href="/_app/immutable/chunks/entry.Bd4ck04i.js">
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.Vg6e9bTg.js">
<link rel="modulepreload" href="/_app/immutable/chunks/index.DtEDIqaG.js">
<link rel="modulepreload" href="/_app/immutable/chunks/control.CYgJF_JY.js">
<link rel="modulepreload" href="/_app/immutable/entry/app.iE8pe31a.js">
<link rel="modulepreload" href="/_app/immutable/chunks/preload-helper.BQ24v_F8.js">
<link rel="modulepreload" href="/_app/immutable/chunks/index.kVFNCZ3-.js">
</head>
<body data-sveltekit-preload-data="hover"; class="overflow-hidden">
<div style="display: contents;">
<script>
{
__sveltekit_1pkutvc = {
base: ""
};
const element = document.currentScript.parentElement;
Promise.all([
import("/_app/immutable/entry/start.mFb7rvTb.js"),
import("/_app/immutable/entry/app.iE8pe31a.js")
]).then(([kit, app]) => {
// console.log("starting...")
kit.start(app, element);
// console.log("started")
});
}
</script>
<script src="webui.js"></script>
</div>
</body>
</html>
|
WAIT -- I think I found the problem -- not a webui thing, so don't waste any more of your time. I switched to Windows dev (from WSL Ubuntu) for Zig, and my Windows CouchDb settings are I think the problem. I'm going down that route and will report back (and probably close this). |
Yes, that's what I was about to write, your server at |
Yes, I had not copied all settings correctly, so the CORS issue is solved. However, the infinite loop (crash / reload) described above is still happening, regardless of where I place the webui.js script (See "NOTE", above). My app starts to load (screenshot): ...but then it seems to be looking for index.html again, cannot find it, crashes, and sveltekit reloads. Here's the console (pink is crashing, all the white logs are successful API calls; this repeats in a loop): |
If you want to use a custom web server with WebUI, you can then look at this C example on how to do that. https://github.com/webui-dev/webui/blob/main/examples/C/custom_web_server/main.c |
Thanks, but no I don't need to write a server, it's just a SvelteKit SPA, with only client-side code. (SvelteKit can do server side, and is probably used mostly for that, but it also does SPAs by turning off all server-side stuff.) The SPA makes many fetch calls to APIs that are separate apps. I have a suspicion about what's happening, and that the problem is due to SvelteKit's client-side router or other code that SvelteKit generates. (SvelteKit does a ton behind the scenes, which is why it's so easy to write apps. But this ton of stuff is all compiled and mostly impenetrable by me.) Anyway, what I think is happening:
I'll figure it out and, if it's of interest to the WebUI community I'll post back. Closing this for now. |
Yes, I'm interested in learning more about this issue. We can improve WebUI or add a new option to make it more flexible to handle this kind of situation. When you have free time. Thank you. |
It seems to be a fundamental conflict with how SvelteKit works. I created a test project that has the same problem. The project is linked to in the new issue I opened: #392 |
Greetings,
(I'm on day 1 of learning WebUI and day 1 of learning Zig, so...)
I have an SPA build (compiled SvelteKit JavaScript linked in index.html).
The SPA calls to two localhost API backends (on ports 3000 and 5984).
It works fine when I serve index.html with node, or when I do a Tauri build.
But when I try a
zig-webui
build, all JavaScriptfetch
calls fail due to CORS.Here's my
main.zig
:Thank you for any advice.
The text was updated successfully, but these errors were encountered: