0

I have a flask app and I want to send a request with Ajax from my page to another website on the internet( http://hihihi.com/v1/user_likes...for example and this App not flask and I can't change or add any code in the hihihi App). I set a cookie in my Ajax requests but blocked by the browser. how can I fix this?

Back end flask:

@app.route('/tr')
def test():
    return render_template('tr.html')

And in tr.html file as shown as I set header Ajax:

 $.ajax({
                    url: 'http://hihihi.com/api',
                    type: 'POST',
                    contentType: 'application/json',headers:{'Cookie' :  'sdfsdfsdfsfdszfvgzzf'}
                    datatype: 'json',
                   
                })
                .done(function(data) {
.
.
.

Refused to set unsafe header "Cookie" Error: Refused to set unsafe header "Cookie"

In addition, I use this link but not work for me.

ablmmcu
  • 161
  • 1
  • 15
Tomy
  • 225
  • 5
  • 18

1 Answers1

0

Since you are making a same origin request all you need to do is set document.cookie before you make the request.

hiep28
  • 1
  • How can I do this? i set like `document.cookie = "username=John Doe";` but not work and It has the same problem as before – Tomy Jun 13 '21 at 18:50
  • There is no way to change the cookies for a different origin from the current origin – hiep28 Aug 11 '21 at 04:04