halfzebra/create-elm-app

Proxy not working if Browser.application is used

ad-si opened this issue · 1 comments

ad-si commented

Is this a bug report?

Yes

Environment

  1. node -v: v16.10.0
  2. npm -v: 7.24.1
  3. npm ls create-elm-app -g:
    /usr/local/lib
    └── create-elm-app@5.22.0

Then, specify:

  1. Operating system: macOS Catalina 10.15.7 19H1419 x86_64

Steps to Reproduce

  1. Start a JSON API server at http://localhost:8081 serving an /items endpoint
  2. Add this to elmapp.config.js
    module.exports = {
      proxy: "http://localhost:8081",
    }
  3. Create Elm app like:
    main : Program () Model Msg
    main =
        Browser.application
            { view = view
            , init = \_ -> \_ -> \_ -> init
            , update = update
            , subscriptions = always Sub.none
            , onUrlRequest = \_ -> NoOp
            , onUrlChange = \_ -> NoOp
            }
  4. Start elm app with npx elm-app start

Expected Behavior

http://localhost:3000/items should serve the JSON

Actual Behavior

Serves the same Elm app as under http://localhost:3000


I assume that the problem is the interaction with Browser.application, but I'm not sure about that.

ad-si commented

So the proxy is actually working, but you can't open it in the browser! 😅
Because of the requested Content-Type I guess?

I leave this issue open as "Improve documentation on how proxy is working exactly"