Cookies are not sent for proxy redirects

while sending request to one of my lambda functions, using the proxy URL, the cookie is not being sent.

My netlify.toml looks like,

[[redirects]]
    from="/exampleFunc"
    to="/.netlify/functions/exampleFunc"
    status=200

cookies do get sent if I send request to /.netlify/functions/exampleFunc

but not with /exampleFunc.

Hmm, could you share your function URL so we can take a look?

it’s deployed at
https://editor-for-noteit.netlify.app/submitNote (proxy to ./netlify/functions/submitNote)

here is my github repo as well,

Thanks! How can I connect to it? I get an HTTP 400 error, with a naive GET to either path. If it’s a POST with a body, or a cookie or header needs to be set, please let me know exactly what should be there.

You should send a POST request with a body.
And from what I understand about the web, cookies get sent automatically for every request.

But that’s not the case for /submitNote.
The cookie do get send if I request /.netlify/functions/submitNote.

Doesn’t seem to work for me when I try:

$ curl -v -XPOST -d{} https://editor-for-noteit.netlify.app/submitNote
*   Trying 206.189.73.52:443...
* Connected to editor-for-noteit.netlify.app (206.189.73.52) port 443 (#0)

> POST /submitNote HTTP/1.1
> Host: editor-for-noteit.netlify.app
> User-Agent: curl/7.70.0
> Accept: */*
> Content-Length: 2
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 502 Bad Gateway
< Cache-Control: no-cache
< Date: Fri, 04 Sep 2020 00:34:43 GMT
< Content-Length: 378
< Content-Type: text/plain; charset=utf-8
< Age: 1
< Connection: keep-alive
< Server: Netlify
< X-NF-Request-ID: 068bdf4f-3305-4136-ae4d-73ef1462120e-27461698
<
* Connection #0 to host editor-for-noteit.netlify.app left intact
{"errorType":"TypeError","errorMessage":"Cannot read property 'match' of undefined","trace":["TypeError: Cannot read property 'match' of undefined","    at extractCookie (/var/task/src/functions/submitNote/submitNote.js:7:37)","    at Runtime.exports.handler (/var/task/src/functions/submitNote/submitNote.js:21:26)","    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"]}

It’s throwing an error because there is no cookie in the request header(which is my exact problem).
I am trying to extract the cookie, which is not being sent.

The cookie gets sent for /.netlify/functions/submitNote but not for /submitNote.

I don’t see that. I got the same behavior for both paths.

It errors out because it’s not receiving any cookies in the header.

OK. Let’s start over.

Please provide a command line with which I can see the difference between the two execution methods. It needs to have EVERYTHING I need to see the problem. So this probably includes:

  • a cookie (name and value)
  • potentially, some POST data (I am sending {} because you did not specify anything except “POST some data”).

I’d like to see you successfully call the function via curl in your response, so I can reproduce what you are seeing, to try to help undertstand the situation. Without more details, nobody can help you :slight_smile:

Thanks in advance for your help!