ghcjs / jsaddle

JavaScript interface that works with GHCJS or GHC
116 stars 62 forks source link

jsaddle-warp: Configurable connection url? #17

Open eskimor opened 7 years ago

eskimor commented 7 years ago

Thanks to your help, I managed to setup my app with jsaddle-warp, everything compiles and runs and loads, but the app does not show up, no errors, no exceptions, just nothing happening. I reduced my main to the following, still no output:

main :: IO ()
main = do
  putStrLn "Run it baby!"
  run 3709 $ do
    liftIO $ putStrLn "Before console.log"
    _ <- JS.eval("console.log('ehehehehe we are here!');" :: Text);
    liftIO $ putStrLn "After console.log"
    pure ()

The only output I am getting is "Run it baby!", nothing else, neither in the browser console nor in the terminal.

Backend is serving an index.html, which loads jsaddle.js, which indeed connects to the frontend (no errors).

Thank you, for any help/pointers/fixes!

eskimor commented 7 years ago

I just tried the obvious: When I connect directly to localhost:3709 the output shows up! .. Investigating ...

eskimor commented 7 years ago

Ok, I think I know the reason: The connect function in jsaddle.js uses the window.location for dermining how to connect to front, which in my case is the wrong thing to do, because there the backend is listening.

Maybe this behaviour should be configurable somehow?

eskimor commented 7 years ago

Just copied and adapted the script for now! it works!!!!!!! Blazingly fast! Awwwwwwesome! Sooooo coool!

eskimor commented 7 years ago

An easy way would be to just check a variable like 'jsaddle_server_url" and use that value if available. I could provide a PR for such a feature, if you are interested.