You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm creating javascript for customers to embed on their website. The embedded script from my server makes requests to the same server to pull data. If you've ever used Typekit, it's a similar setup, although I'm not serving fonts.
When I deploy, the URL for the app necessarily changes. In Konacha tests, it seems to be 127.0.0.1:[random port]. In my development environment it's localhost:3000. In production, it's the address of my website. I'm using a .js.erb file to construct a dynamic url off of root_url to make sure I'm hitting the right server URL for tests and production and not getting cross origin requests errors.
If I use <%= root_url %>, I get the error:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
So I need to set the host from the current rails app. In a real development or production environment, I can use request.host_and_port but Konacha doesn't use the rails request object.
So my question is, how can I set the host so it works in both my test, development, and production environments? Am I going about this the wrong way? Is there some way I can access the rails request object during a Konacha test?
The text was updated successfully, but these errors were encountered:
So I just tried this and it made all tests work in my development environment, but not for my staging environment. The problem is that my embedded script needs to hit my ever-changing server's address. Mounting konacha fixes the test vs dev environment issue, but I still need to specify the full URL.
Am I understanding this right? How do you hit a different URL when you deploy vs when you test?
I'm creating javascript for customers to embed on their website. The embedded script from my server makes requests to the same server to pull data. If you've ever used Typekit, it's a similar setup, although I'm not serving fonts.
When I deploy, the URL for the app necessarily changes. In Konacha tests, it seems to be
127.0.0.1:[random port]
. In my development environment it'slocalhost:3000
. In production, it's the address of my website. I'm using a.js.erb
file to construct a dynamic url off ofroot_url
to make sure I'm hitting the right server URL for tests and production and not getting cross origin requests errors.If I use
<%= root_url %>
, I get the error:So I need to set the host from the current rails app. In a real development or production environment, I can use
request.host_and_port
but Konacha doesn't use the rails request object.So my question is, how can I set the host so it works in both my test, development, and production environments? Am I going about this the wrong way? Is there some way I can access the rails request object during a Konacha test?
The text was updated successfully, but these errors were encountered: