You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently I'm trying to get Jupyter to call emacs edit server via an extension. Unfortunately this fails due to a CORS error.
This can be resolved by adding "Access-Control-Allow-Origin: *\n" to the response header as follows:
(defun edit-server-send-response (proc &optional body progress)
"Send an HTTP 200 OK response back to process PROC.
Optional second argument BODY specifies the response content:
- If nil, the HTTP response will have null content.
- If a string, the string is sent as response content.
- Any other value will cause the contents of the current
buffer to be sent.
If optional third argument progress is non-nil, then the response
will include x-file and x-open headers to allow continuation of editing."
(interactive)
(edit-server-log proc "sending edit-server response")
(if (processp proc)
(let ((response-header (concat
"HTTP/1.0 200 OK\n"
(format "Server: Emacs/%s\n" emacs-version)
"Date: "
(format-time-string
"%a, %d %b %Y %H:%M:%S GMT\n"
(current-time))
"Access-Control-Allow-Origin: *\n"
(when progress
(format "x-file: %s\nx-open: true\n" (buffer-name))))))
(process-send-string proc response-header)
(process-send-string proc "\n")
(cond
((stringp body)
(process-send-string proc (encode-coding-string body 'utf-8)))
((not body) nil)
(t
(encode-coding-region (point-min) (point-max) 'utf-8)
(process-send-region proc (point-min) (point-max))))
(process-send-eof proc)
(edit-server-log proc "Editing done, sent HTTP OK response."))
(message "edit-server-send-response: invalid proc (bug?)")))
Alternately one could also provide an edit-server-extra-http-headers param in config.
The text was updated successfully, but these errors were encountered:
Currently I'm trying to get Jupyter to call emacs edit server via an extension. Unfortunately this fails due to a CORS error.
This can be resolved by adding
"Access-Control-Allow-Origin: *\n"
to the response header as follows:Alternately one could also provide an
edit-server-extra-http-headers
param in config.The text was updated successfully, but these errors were encountered: