I want to send a cookie back with the file (its purpose is to be detected by my React app so it knows the file has been downloaded). I tried to simply do:
The file method is given you back a BinaryFileResponse object. You can't call cookie on that, and that's why you get the server error. It's trying to call a method that doesn't exist.
There is another way and that's just setting a session for example in your application or update a database row and do a request to that after that. So you call an url to check if the download has been done or not. However you don't know when or if the download was successful that way. Note that you also don't know that with a cookie of course.