Rasa version: Rasa 1.10.1
Python version: 3.6.9
Operating system: Ubuntu 18.04.3 LTS (Bionic Beaver)
Issue:
I train a model using HTTP /model/train API and want to get a trained model filename as response header as defined in docs.
Unfortunately it seems like I can't do this: browser doesn't see response 'filename' header.
All I get are following:
HTTP/1.1 200 OK
Connection: keep-alive
Keep-Alive: 5
Access-Control-Allow-Origin: http://localhost:3000
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Max-Age: None
Access-Control-Allow-Methods: DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT
Vary: Origin
Content-Length: 0
Looks like this is issue about 'Access-Control-Expose-Headers'. Can we add 'filename' to exposed headers?
Can you post the request you're making/how you're making it? I do see the filename header returned with the request below:
curl --request POST --url http://localhost:5005/model/train \
--output model.tar.gz \
--header 'content-type: application/json' \
--data '{
"domain": "intents:\n - greet\n - goodbye\n - affirm\n - deny\n - mood_great\n - mood_unhappy\n\nactions:\n - utter_greet\n - utter_cheer_up\n - utter_did_that_help\n - utter_happy\n - utter_goodbye\n\ntemplates:\n utter_greet:\n - text: \"Hey! How are you?\"\n\n utter_cheer_up:\n - text: \"Here is something to cheer you up:\"\n image: \"https://i.imgur.com/nGF1K8f.jpg\"\n\n utter_did_that_help:\n - text: \"Did that help you?\"\n\n utter_happy:\n - text: \"Great carry on!\"\n\n utter_goodbye:\n - text: \"Bye\"",
"config": "language: en\npipeline: supervised_embeddings\npolicies:\n - name: MemoizationPolicy\n - name: KerasPolicy",
"nlu": "## intent:greet\n- hey\n- hello\n- hi\n## intent:goodbye\n- bye\n- goodbye\n- have a nice day\n- see you\n## intent:affirm\n- yes\n- indeed\n## intent:deny\n- no\n- never\n## intent:mood_great\n- perfect\n- very good\n- great\n## intent:mood_unhappy\n- sad\n- not good\n- unhappy",
"stories": "## happy path\n* greet\n\n - utter_greet\n\n* mood_great\n\n - utter_happy\n\n## sad path 1\n* greet\n\n - utter_greet\n\n* mood_unhappy\n\n - utter_cheer_up\n\n - utter_did_that_help\n\n* affirm\n\n - utter_happy\n\n## sad path 2\n* greet\n\n - utter_greet\n\n* mood_unhappy\n\n - utter_cheer_up\n\n - utter_did_that_help\n\n* deny\n\n - utter_goodbye\n\n## say goodbye\n* goodbye\n\n - utter_goodbye",
"force": false,
"save_to_default_model_directory": true
}' --dump-header header.txt
header.txt contains:
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Connection: keep-alive
Keep-Alive: 5
filename: 20200629-154807.tar.gz
Content-Disposition: attachment; filename="20200629-154807.tar.gz"
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Content-Length: 1916881
Content-Type: application/x-tar
@melindaloubser1, sure, curl or other tool like that will see custom header. But for js code in browser it won't be accessible by default. Please check this link for more info.
I have prepared a demo app here, you can reproduce this yourself.
It starts a simple react app, containing one button which launches model training at http://localhost:5005 and prints to browser console available response's headers:

Then add the line here to configure sanic-cors:
app.config.CORS_EXPOSE_HEADERS = '*'
After that much more info is available to browser:

Or less broadly:
app.config.CORS_EXPOSE_HEADERS = 'filename'

If one of options above is suitable for you I can create a PR.
Ok that makes sense! Yes, if you could open a PR for exposing just filename additionally that'd be great.
@melindaloubser1 created a PR. Please check it when you have time.
@Ezhvsalate I don't think the commit you linked to is actually part of a PR, I left a comment on it