question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trouble proxying http requests to localhost server using Ember

See original GitHub issue

I’m trying to get HTTP requests to proxy to my local api server, which is running on port 3000 on my machine.

I’ve configured polly as such:

    pollyjs: {
      enabled: EmberApp.env() !== 'production',
      server: {
        apiNamespace: 'polly',
        recordingsDir: 'recordings'
      }
    }

If I just start the app using ember s then the api calls do not get proxied over to my local server. This isn’t suprising, since I haven’t told the app anywhere to do so. If I start the app using ember s -proxy=http://localhost:3000 then the ember app tries to forward the call to polly over to my local server, which obviously doesn’t exist and returns a 404:

http://localhost:4200/polly/Acceptance-Projects-Test_1427335148%2FList-of-Projects_1960582640/c7891a5bc919b6b46c122f196338f0b2?order=0

Looking at the documentation, I’m unclear how to get this working. Is there some sort of configuration I need to do in the express server created by polly on the ember app? Or did I just configure polly wrong in .ember-cli-build?

Also I have a test app up with the code I’m using https://github.com/andrewcallahan/test-app

Thanks in advance! Really hoping to get this working!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
offirgolancommented, Jul 20, 2018

Is, polly supposed to set up a server that listens at that endpoint? or am I supposed to set up some small express thing that polly uses?

@NullVoxPopuli that is correct. If you are using the REST Persister (which it looks like you are), a server must be stood up to support the polly requests. You can follow the setup instructions here.

If you dont want recording/replaying, you will need to upgrade to v1.0.0 that way you can add mode: passthrough to your configuration which will pass through all requests that you havent manually intercepted.

1reaction
offirgolancommented, Jun 21, 2018

@kennethlarsen the windows issue should’ve been resolved by #32.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember CLI and Rails: Error proxying to http://localhost:3000
Try setting up in your embers config/environment.js for each environment proper URL and settings. More info here. ENV.contentSecurityPolicy = { ...
Read more >
How to setup Ember (with or without cli) to use already ...
From the docs: “ember server - Starts the server. The default port is 4200. Use the --proxy flag to proxy all ajax requests...
Read more >
Ember and Rails 5 with JSON API: A Modern Bridge
Let's boot Ember CLI server. We are going to use the --proxy flag to let it know our backend is listening at port...
Read more >
How To Setup Your Ember Project With Mongo and Node
The Ember server is running on port 4200 with a proxy to the Node server running on port 3000. This works fine and...
Read more >
Developing an Ember.js app on https - Balint Erdi
This shouldn't affect the way we develop web applications locally as localhost is considered a secure origin, even if used with http.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found