0

I have an app that is built on top of Vue.js and Rails.

When a button is clicked, it will fire an API call (eg. POST api.example.com/create) to the Rails backend.

NOTE: The frontend (eg. blog.example.com) and backend (eg. api.example.com) have different subdomains

I would like to test the flow using Capybara but whenever I simulate the click on the button, it will return net::ERR_CONNECTION_REFUSED error on the frontend.

My assumption is I need to configure my Capybara to adapt to this setup but I can't figure out what am I missing here.

I have tried to set

config.server_host = 'http://api.example.com'

OR

config.app_host = 'http://api.example.com'

but both didn't work for me.

Sam Kah Chiin
  • 4,375
  • 5
  • 25
  • 30
  • Does this answer your question? [Capybara with subdomains - default\_host](https://stackoverflow.com/questions/6536503/capybara-with-subdomains-default-host) – Sampat Badhe Jun 09 '22 at 13:22
  • 1
    @SampatBadhe Unfortunately no. If I understand it correctly, that question is about the scenario when both the FE and BE share the same subdomain (but different subdomains for different tenants). In my case, the FE and BE have different subdomains. – Sam Kah Chiin Jun 09 '22 at 17:31
  • What driver are you using? – Thomas Walpole Jun 10 '22 at 01:40
  • `selenium_chrome_headless_docker_friendly` @ThomasWalpole – Sam Kah Chiin Jun 10 '22 at 04:16
  • You need to ensure that api.example.com and blog.example.com resolve, in your environment, to the ip address of the machine your AUT is being run on, or swap to a domain that does – Thomas Walpole Jun 10 '22 at 05:01
  • Can you elaborate this further in codes @ThomasWalpole? Thanks! – Sam Kah Chiin Jun 10 '22 at 05:32
  • @SamKahChiin It's not a code thing, it would be a local DNS configuration thing - or you could swap to using something like https://nip.io (rather than example.com) if you don't have the ability to modify your local DNS resolutions – Thomas Walpole Jun 12 '22 at 20:02

0 Answers0