title: FastApi cannot write cookie in reponse, in docker on vps, how to fix?
body: <p>Cannot to sign in, i run localy in docker my container, i can sign-in on my machine and docker no error, but on my remote server i cannot to login, <code>it doesn't write cookie in reponse</code>, <code>have no error</code>, just don't write response. It just redirect me on my page which i setted,and after that i got error, cause i have no my cookie authorization key inside cookie.</p>
  <p><a href="https://youtu.be/ZcXX3eOI12U" rel="nofollow noreferrer">video</a></p>
  <p>My SignIn method</p>
  <pre><code>@auth_router.post('/signin')
  async def sign_in(response: Response, username: str = Form(...), password: str = Form(...), recaptchav3: str = Form(...)) -&gt; dict:
  
      is_human = await verify_recaptcha(recaptchav3)
      if is_human['success']:
          user = await authenticate_user(username, password)
  
          if not user:
              raise HTTPException(
                  status_code=status.HTTP_401_UNAUTHORIZED,
                  detail='Invalid username or password',
              )
  
          user_obj = await User_Pydantic.from_tortoise_orm(user)
          user_token = await generate_token(user_obj)
  
          response.set_cookie(key=&quot;Authorization&quot;, value=user_token, httponly=True, secure=True, expires=(8*60*60))
          response.headers[&quot;Authorization&quot;] = user_token
  
          user.jwt_token = user_token
          await user.save()
  
          return {
              'access_token': user_token,
              'token_type': 'bearer'
          }
      else:
          raise HTTPException(
              status_code=status.HTTP_400_BAD_REQUEST,
              detail='Invalid captcha',
          )
  </code></pre>
  <p>How i submit my form js</p>
  <pre><code>const request = (method, url, data = null, redirectPage) =&gt; {
      return new Promise((resolve, reject) =&gt; {
          let xhr = new XMLHttpRequest()
          xhr.open(method, url, true)
          // xhr.setRequestHeader('Content-Type', 'multipart/form-data')
          xhr.onerror = function (event) {
              alert(event)
              console.log(event);
          };
          xhr.onload = () =&gt; {
          if (xhr.status === 200) {
              return window.location.href = redirectPage;
              return resolve(JSON.parse(xhr.responseText || '{}'))
              } else {
                  alert(`Request failed with status ${xhr.status}`)
                  reject(new Error(`Request failed with status ${xhr.status}`))
                  
                  return window.location.reload();
              }
          } 
  
          if (data) {
              if (typeof data === 'string' || data instanceof String || typeof data.constructor == Object){
                  xhr.send(JSON.stringify(data))
              } else {
                  xhr.send(data)
              }
          } else {
              xhr.send()
          }
  
  
      })
  }
  
  
  
  
  signInForm = getElementById('signinform');
  handleEvent(signInForm, 'submit', e =&gt; {
      e.preventDefault();
  
      if(!isEmpty(signInForm)){
  
          signInUsername = getElement('input[name=&quot;username&quot;]', signInForm).value;
          signInPassword = getElement('input[name=&quot;password&quot;]', signInForm).value;
          recaptchaV3 = getElement('[name=&quot;g-recaptcha-response&quot;]').value;
  
          if(recaptchaV3){
              signInData = new FormData();
              signInData.append('username', signInUsername);
              signInData.append('password', signInPassword);
              signInData.append('recaptchav3', recaptchaV3);
  
              isLogened = request('POST', '/signin', signInData, 'dashboard');
  
              
          } else{
              alert('Перезагрузите страницу');
          }
  
      }
  
  })
  </code></pre>