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.

Passthrough not working for cross-origin requests

See original GitHub issue

Hi,

I am setting up my routes like so:

new Server({
	routes() {
		this.post(<some-fully-qualified-route>, {...});

		this.post(<another-fully-qualified-route>, {...});

		this.passthrough();
	}
});

This only passes through requests made on same origin but does nothing for the other cross-origin requests. Is this an expected behaviour? If yes, how can we achieve pass-through behaviour for all remaining request except for the one mentioned explicitly in the routes?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
samselikoffcommented, Mar 25, 2020

You can pass through all requests for a single domain like this

this.passthrough('http://api.amazon.com/**')

but unfortunately you can’t wildcard all domains. But, passthrough has a function version that you can use to perform whatever check you want:

this.passthrough(request => {
  return request.url.match(/regex/)
})

Let me know if that helps! Here are the full passthrough guides. I know this is a confusing API today, we have plans to improve it so you can passthrough anything that is not defined, and that’s very high priority behind some other stuff we’re working on now.

0reactions
ryantocommented, May 20, 2020

Hi @rassie

Maybe only evaluate and apply this.passthroughChecks if originalCheckPassthrough is false?

I think this seems reasonable, but I’m having a hard time visualizing a config that highlights this change. Could you share your server’s routes and examples of requests you’d like mirage to handle vs passthrough. That’ll help!

I think getting a test case of sorts in place is the best way to see what’s going on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cross origin requests #19 - miragejs/ember-cli-mirage - GitHub
What I'm trying to do is build a prototype backed by Ember-CLI-Mirage that uses Algolia for searching. I either need a way to...
Read more >
Integration passthrough behaviors - Amazon API Gateway
For proxy integrations, API Gateway passes the entire request through to your backend, and you do not have the option to modify the...
Read more >
I get a cross-origin error when making a HTTP requests
I noticed that I can to enter Application_BeginRequest but not into my function in the controller,which means CORES privilege issue.
Read more >
Implement CORS in API Gateway - Alibaba Cloud
By using this mechanism, you can enable the browser to allow cross-origin requests. image. 2. CORS overview. 2.1 Two request validation modes.
Read more >
React CORS Guide: What It Is and How to Enable It - StackHawk
See it in action and learn how to enable CORS in a React application. ... for requests from different origins are allowed to...
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