Fix inability to use local LibreTranslate without setting ALLOWED_PRIVATE_ADDRESSES (#21926)
Fixes #20029
This commit is contained in:
parent
bbc49f15e0
commit
673c54f114
|
@ -30,7 +30,8 @@ class Request
|
||||||
@verb = verb
|
@verb = verb
|
||||||
@url = Addressable::URI.parse(url).normalize
|
@url = Addressable::URI.parse(url).normalize
|
||||||
@http_client = options.delete(:http_client)
|
@http_client = options.delete(:http_client)
|
||||||
@options = options.merge(socket_class: use_proxy? ? ProxySocket : Socket)
|
@allow_local = options.delete(:allow_local)
|
||||||
|
@options = options.merge(socket_class: use_proxy? || @allow_local ? ProxySocket : Socket)
|
||||||
@options = @options.merge(proxy_url) if use_proxy?
|
@options = @options.merge(proxy_url) if use_proxy?
|
||||||
@headers = {}
|
@headers = {}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TranslationService::LibreTranslate < TranslationService
|
||||||
|
|
||||||
def request(text, source_language, target_language)
|
def request(text, source_language, target_language)
|
||||||
body = Oj.dump(q: text, source: source_language.presence || 'auto', target: target_language, format: 'html', api_key: @api_key)
|
body = Oj.dump(q: text, source: source_language.presence || 'auto', target: target_language, format: 'html', api_key: @api_key)
|
||||||
req = Request.new(:post, "#{@base_url}/translate", body: body)
|
req = Request.new(:post, "#{@base_url}/translate", body: body, allow_local: true)
|
||||||
req.add_headers('Content-Type': 'application/json')
|
req.add_headers('Content-Type': 'application/json')
|
||||||
req
|
req
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue