Coder Social home page Coder Social logo

Proxying does not work about elm-live HOT 7 CLOSED

Ploppz avatar Ploppz commented on June 20, 2024
Proxying does not work

from elm-live.

Comments (7)

Ploppz avatar Ploppz commented on June 20, 2024 1

Ahh missed that, sorry

from elm-live.

julianpistorius avatar julianpistorius commented on June 20, 2024 1

No problem! Glad to hear you're up & running. 👋

from elm-live.

julianpistorius avatar julianpistorius commented on June 20, 2024

This is correct. The browser makes a request to http://localhost:8000/api/v1/measurements, served by elm-live. Then under the hood the elm-live server will proxy the request to http://localhost:8443/api/v1/measurements.

from elm-live.

Ploppz avatar Ploppz commented on June 20, 2024

Ah, I understand.

But I still have a problem: The requests it sends return 404.

For example I see in the Network tab GET http://localhost:8000/api/v1/measurements that resulted in 404.
But if I run curl http://localhost:8443/api/v1/measurements, it is successful.

from elm-live.

malaire avatar malaire commented on June 20, 2024

It looks like proxy prefix is deleted from URL: https://github.com/wking-io/elm-live/blob/master/lib/src/start.js#L187

i.e. http://localhost:8000/api/v1/measurements would be proxied to http://localhost:8443/v1/measurements with --proxy-prefix '/api'

from elm-live.

Ploppz avatar Ploppz commented on June 20, 2024

Huh, that makes little sense. Thanks for figuring that out.

Now I'm unsure how I can achieve what I want:
I want to locally run the app with elm-live and proxy all requests to an API running on a different port.
In production, I want the same Elm code to send a request to the path part of URL: /api/v1/, so if it's running on example.com and sends a request to /api/v1/something, it gets sent to example.com/api/v1/something

from elm-live.

julianpistorius avatar julianpistorius commented on June 20, 2024

@Ploppz Add /api to the proxy-host as well, like so:

elm-live src/Main.elm --proxy-prefix '/api' --proxy-host 'http://localhost:8443/api' --  --output elm.js

See https://www.elm-live.com/#getting-started and scroll down to documentation for --proxy-prefix:

NOTE: The string passed to --proxy-prefix will be removed from the --proxy-host url. If you would like the url to include the prefix just add it there as well like: http://localhost:5000/api

from elm-live.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.