Open zmrocze opened 1 year ago
Local
Add a proxy that sets Access-Control-Allow-Origin: *
(or better, the origin you will be using, i.e. the hostname)
Deployment
I think it must be wss
(secure: true) - do you have the full parameters for this deployment for me to check if that's the problem?
Github pages
Same
Local
Do you mean a proxy on ctl-runtime (or even just on kupo)?
Deployment, Gh Pages
Note that deploy and gh-pages above had different error messasages.
Now after setting secure: true
in ContractParams here BOTH return the same error (the same as deployment previously):
[DEBUG] 2023-05-23T18:49:48.591Z Created a new WebSocket
reconnecting-websocket-mjs.js:537 WebSocket connection to 'wss://ogmios.preview.ctl-runtime.staging.mlabs.city:1337/' failed: WebSocket is closed before the connection is established.
t._disconnect @ reconnecting-websocket-mjs.js:537
_handleError @ reconnecting-websocket-mjs.js:178
t._handleTimeout @ reconnecting-websocket-mjs.js:527
(anonymous) @ reconnecting-websocket-mjs.js:522
setTimeout (async)
(anonymous) @ reconnecting-websocket-mjs.js:522
Promise.then (async)
t._connect @ reconnecting-websocket-mjs.js:510
t @ reconnecting-websocket-mjs.js:203
(anonymous) @ Offchain.js:13677
(anonymous) @ Offchain.js:29444
I @ Offchain.js:8242
V @ Offchain.js:8477
run @ Offchain.js:8786
(anonymous) @ Offchain.js:9107
k @ Offchain.js:9146
(anonymous) @ Offchain.js:9160
I @ Offchain.js:8242
V @ Offchain.js:8477
(anonymous) @ Offchain.js:8783
a @ Offchain.js:8264
enqueue @ Offchain.js:8285
run @ Offchain.js:8782
(anonymous) @ Offchain.js:9795
(anonymous) @ Offchain.js:5448
(anonymous) @ Offchain.js:5448
(anonymous) @ Offchain.js:35252
(anonymous) @ Offchain.js:35247
e.unsafePerformEffect @ Offchain.js:46746
(anonymous) @ Offchain.js:47318
n.payToPassword @ Offchain.js:47502
(anonymous) @ App.tsx:146
(anonymous) @ 917.main.js:1
(anonymous) @ 917.main.js:1
(anonymous) @ 917.main.js:1
onClick @ 917.main.js:1
Ie @ react-dom.production.min.js:54
$e @ react-dom.production.min.js:54
(anonymous) @ react-dom.production.min.js:55
Mr @ react-dom.production.min.js:105
Dr @ react-dom.production.min.js:106
(anonymous) @ react-dom.production.min.js:117
fc @ react-dom.production.min.js:274
Te @ react-dom.production.min.js:52
qr @ react-dom.production.min.js:109
Gt @ react-dom.production.min.js:74
Ht @ react-dom.production.min.js:73
Show 15 more frames
Offchain.js:13429 [ERROR] 2023-05-23T18:49:52.605Z First connection to ogmios WebSocket failed. Terminating. Error: [object Object]
Offchain.js:5504 Uncaught (in promise) Error: [object Object]
at e.error (Offchain.js:5504:12)
at Offchain.js:29450:83
at t (Offchain.js:13701:7)
at t._callEventListener (reconnecting-websocket-mjs.js:555:13)
at reconnecting-websocket-mjs.js:183:79
at Array.forEach (<anonymous>)
at t._handleError (reconnecting-websocket-mjs.js:183:36)
at t._handleTimeout (reconnecting-websocket-mjs.js:527:14)
at reconnecting-websocket-mjs.js:522:75
Context
The flake provides two convenience applications for serving the webapp:
which differ only in the URLs defined for kupo/ogmios in ContractParams, and then in turn in the final js bundles for the app. See section
About ContractParams
of README and browse for tagsSwitchContractParams
in source to find all related bits of code.The applications are simple calls of
http-server
on the app bundles. See flake.nix/run-frontend-app.Problem description
In both instances application errors when connecting to ctl-runtime, but differently.
Local
I defined a branch
debug-connections
(debug-connections) that points Kupo to the default ctl-runtimelocalhost:1442
. (thats only difference to main, which instead points to "localhost:4008/kupo"). Running firstthen
and interacting with the application yields in the browser console:
So is this the cors policy from kupo, run by ctl-runtime that blocks it?
Deployment
Deployment targets the public mlabs ctl-runtime instances
Running
and interacting with the application yields in the browser console:
Is it actually a server timeout? I doesn't look like because of the warning: "WebSocket is closed before the connection is established".
Github pages
Another problem happens with hosting the public mlabs instances version on github pages (https://mlabs-haskell.github.io/the-plutus-scaffold/):
Is there easy fix?
So there's the proxy with the setting
changeOrigin
in the dev-server from ctl-scaffold, is it related to this issue? How to replicate that with http-server and without modifying ctl-runtime?I think the fix would be easy if the project provides full deployment server, then ctl-runtime can just be pinged at different url's served by the same server (if the problem is related to cors). But is there a fix to just provide a convenience flake app server, keeping the website fully static?