rtfeldman / elm-spa-example

A Single Page Application written in Elm
https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa
MIT License
3.28k stars 530 forks source link

Where in the docs does it explain how to build the front-end for a local RealApp backend? #74

Open dnk8n opened 5 years ago

dnk8n commented 5 years ago

I may be missing something obvious, but I would expect this in the README.txt of the repo.

SidneyNemzer commented 5 years ago

It looks like the API URL is hardcoded here:

https://github.com/rtfeldman/elm-spa-example/blob/c8c3201ec0488f17c1245e1fd2293ba5bc0748d5/src/Api/Endpoint.elm#L56

dnk8n commented 5 years ago

I found that and changed it. I then rebuilt the elm app, however for a reason I cannot understand it still points to the productionready.io target.

I attempted to clear the app data, etc.

No success.

SidneyNemzer commented 5 years ago

It will be hard to help without seeing your code. Do you have it on Github maybe?

dnk8n commented 5 years ago

I have made no other changes to the github project of this issue

On Fri, Apr 12, 2019, 6:44 AM Sidney Nemzer notifications@github.com wrote:

It will be hard to help without seeing your code. Do you have it on Github maybe?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rtfeldman/elm-spa-example/issues/74#issuecomment-482435280, or mute the thread https://github.com/notifications/unsubscribe-auth/ADJ46WwQR4imuhDdVqAMhuaA_kaFBZVaks5vgA8_gaJpZM4cqU3r .

dnk8n commented 5 years ago

All I did was run a Django server with the RealWorld API on localhost:8000

I want the front end to talk to it.

On Fri, Apr 12, 2019, 1:51 PM Dean Kayton deankayton@gmail.com wrote:

I have made no other changes to the github project of this issue

On Fri, Apr 12, 2019, 6:44 AM Sidney Nemzer notifications@github.com wrote:

It will be hard to help without seeing your code. Do you have it on Github maybe?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rtfeldman/elm-spa-example/issues/74#issuecomment-482435280, or mute the thread https://github.com/notifications/unsubscribe-auth/ADJ46WwQR4imuhDdVqAMhuaA_kaFBZVaks5vgA8_gaJpZM4cqU3r .

dnk8n commented 5 years ago

It will be hard to help without seeing your code. Do you have it on Github maybe?

Here is the only code change I have made: https://github.com/dnk8n/elm-spa-example/commit/ac8d0392527d2d2e6a529672c1f63be4bafdb33d

Can anyone shed some light here?

dnk8n commented 5 years ago

Some further information.

To start the web-server I do: elm-live -p 8080 src/Main.elm

and get the following output:

Success! Compiled 1 module.                                          

elm-live:
  The build has succeeded. Starting the server!

Reload web server:
  - Website URL: http://localhost:8080
  - Listening on port: 8080
  - Monitoring dir: /home/.../.../elm-spa-example

elm-live:
  Watching src/**/*.elm.

But then I get the following display on the http://localhost:8080

console_elm network_elm

dnk8n commented 5 years ago

I guess I should state that I am running the RealWorld API from http://localhost:8000. It is the Django backend found at: https://github.com/gothinkster/django-realworld-example-app

I have made no modifications there at all. The API is available (as can be see in the image above, 200 success codes)

dnk8n commented 5 years ago

Note: I also tried: elm make src/Main.elm --output elm.js and http-server

The output is as follows:

Dependencies loaded from local cache.
Dependencies ready!                
Success! Compiled 33 modules.

and

Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8080
  http://192.168.43.178:8080
Hit CTRL-C to stop the server
[Tue Apr 30 2019 09:59:46 GMT+0200 (South Africa Standard Time)] "GET /" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
[Tue Apr 30 2019 09:59:47 GMT+0200 (South Africa Standard Time)] "GET /assets/images/loading.svg" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
[Tue Apr 30 2019 10:00:17 GMT+0200 (South Africa Standard Time)] "GET /" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"

The website looks similar, although I think another problem has crept in here, because last week your master branch displayed correctly and now it is not. Seems it is not able to find the JS and/or the CSS?

billewanick commented 5 years ago

@dnk8n Try updating your whitelist in the Django backend, that might help https://github.com/gothinkster/django-realworld-example-app/blob/master/conduit/settings.py#L132

nicktheo59 commented 4 years ago

Try https://conduit.productionready.io/api if you’re just wanting to kick the tyres.

Interestingly it seems the database/backend for this Elm front-end is shared with the other ‘official’ Real World / Conduit demo .. makes sense since the Elm one is just hosted with (static) Netlify

senorsmile commented 3 years ago

I had the same issue but realized that chrome was aggressively caching content. I went to firefox and saw it going to the correct back end.

Ctrl+f5 forced it to reload.