我正在使用宝石'griddler‘与创业板'griddler-sendgrid’在我的红宝石rails应用程序收到邮件。
它在暂存服务器上运行良好,但在生产服务器上遇到了问题。在我的配置中没有问题,我已经用sendgrid support确认了这一点。他们告诉我只使用DKIM validation,并将SPF check从验证中删除。
我已经检查了这两个宝石,但没有找到任何相关的。
以下是我的创业板配置细节:
ruby‘2.3’ gem 'rails','4.1.2‘ 宝石'griddler','1.4.0‘ gem 'griddler-sendgrid',‘1.0’
有人能建议我如何在gem 'griddler-sendgrid‘中跳过SPF检查验证吗?
提前感谢!
发布于 2018-07-26 11:58:05
试着从github得到emails_controller.rb吗?
https://github.com/thoughtbot/griddler
“用ArgumentError on Rails API修复verify_authenticity_token”
我增加了protect_from_forgery with: :null_session
我认为null_session应该在API控制器中使用,而不需要对会话使用。它在请求期间提供一个空会话。
https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html
在控制器文件夹中,griddler从Griddler添加一个新文件,或者尝试下面的代码。
/控制器/griddler/emails_Controller.rb
class Griddler::EmailsController < ActionController::Base
skip_before_action :verify_authenticity_token, raise: false
protect_from_forgery with: :null_session
def create
normalized_params.each do |p|
process_email email_class.new(p)
end
head :ok
end
private
delegate :processor_class, :email_class, :processor_method, :email_service, to: :griddler_configuration
private :processor_class, :email_class, :processor_method, :email_service
def normalized_params
Array.wrap(email_service.normalize_params(params))
end
def process_email(email)
processor_class.new(email).public_send(processor_method)
end
def griddler_configuration
Griddler.configuration
end
end不完全确定整个解决方案,但希望它将有助于获得更多的方向。
https://stackoverflow.com/questions/50129626
复制相似问题