Get origin of the request in

I would like to set c.NotebookApp.allow_origin dynamically based on the request’s origin. How can I obtain the request’s origin at runtime and set this value? and were helpful but could’t get the entire picture to solve this.

c.NotebookApp.allow_origin_pat can be used to set multiple allowed origins. The Jupyter server will set the corresponding origin URL if it matches the pattern mentioned. Thanks @minrk for the tip!