Skip to content

Commit

Permalink
Address CSRF issues in Rails 5.1+
Browse files Browse the repository at this point in the history
Fixes #557

For AJAX POST requests, we need to pass along Rails' CSRF token in Rails 5.1+
  • Loading branch information
Eric Larson authored and eliotjordan committed Aug 1, 2018
1 parent 6ba4513 commit daf98c2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/geoblacklight/viewers/wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ GeoBlacklight.Viewer.Wms = GeoBlacklight.Viewer.Map.extend({
$.ajax({
type: 'POST',
url: '/wms/handle',
beforeSend: function(xhr) {
xhr.setRequestHeader('X-CSRF-Token', Rails.csrfToken());
},
data: wmsoptions,
success: function(data) {
if (data.hasOwnProperty('error') || data.values.length === 0) {
Expand Down

0 comments on commit daf98c2

Please sign in to comment.