elm-lang / elm-reactor

Interactive development tool that makes it easy to develop and debug Elm programs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: --proxy ala ember-cli

ijcd opened this issue · comments

Add the ability to have a .elm-reactor conf file along w/ a --proxy option that allows you to proxy ajax requests to an api running elsewhere. See EmberCLI for an example.

% cat .ember-cli                                                                                                                                                        {
  "proxy": "https://www.twitch.tv",
  "ssl": true,
  "host": "localhost.twitch.tv"
}

https://ember-cli.com/user-guide/

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

Problem

Let's say we are developing client for some API server. As soon as we want to use elm-reactor alongside real data from this server we are stuck because of CORS policies.

Current state

Right now to achieve this we have 2 options

  1. Do not use elm-reactor and switch to something like webpack-dev-server which provides us with ability to proxy traffic. This solution leads us to step out of Elm stack which may result in worse developer experience and rely on tools which don't keep Elm in mind when doing design decisions. Also you immediately loose any feature elm-reactor can provide you.
  2. Setup CORS policies on API to allow requests in development. This solution pushes client-side developer experience problems to the server which doesn't seems right and may result in security holes.

Possible solution

So as a possible solution elm-reactor can provide flag for proxying all the traffic which do not relate to static assets. Here you can find same solutions provided by ember-cli (see ember server) and create-react-app.