Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative app url #42

Open
dostapn opened this issue Sep 26, 2019 · 2 comments
Open

Relative app url #42

dostapn opened this issue Sep 26, 2019 · 2 comments

Comments

@dostapn
Copy link

dostapn commented Sep 26, 2019

I have root url as /somepath/APP
At plugin.js we have this code:

(function($) {
  $.fn.railsSortable = function(options) {
    options = options || {};
    var settings = $.extend({}, options);
    settings.update = function(event, ui) {
      if (typeof options.update === 'function') {
        options.update(event, ui);
      }
      $.ajax({
        type: 'POST',
        url: '/sortable/reorder',
        dataType: 'json',
        contentType: 'application/json',
        data: JSON.stringify({
          rails_sortable: $(this).sortable('toArray'),
        }),
      });
    }
    this.sortable(settings);
  };
})(jQuery);

need to set variable to url or get it after app initialization.

@skillmatic-co
Copy link
Contributor

+1

@itmammoth I need something similar, my app lives in Shopify so the AJAX needs to hit at the app proxy URL, not the current window's URL. Is there a way to set the base URL for the AJAX calls?

itmammoth added a commit that referenced this issue Mar 27, 2023
[#42] Add base URL to AJAX URL call
@skillmatic-co
Copy link
Contributor

skillmatic-co commented Mar 29, 2023

Thanks @itmammoth, this solved my issue.

@dostapn I assume this would fix your issue as well.

Edit: This solved my issue but did have to update some cors policies in my Rails app. Something along these lines that would be nice in the future is to be able to scope/modify the route. Again, in my Shopify instance, my app lives at /app_proxy/ so, making the route be scoped to 'app_proxy' would have been nice. This would have solved my issue without updating any cors policies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants