isomorphic-git: CORS with Gogs: missing token 'user-agent' in CORS header 'Access-Control-Allow-Headers'

In the browser using the npm package with webpack I get:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8000/BrokenWorld/Editor.git/info/refs?service=git-upload-pack. (Reason: missing token 'user-agent' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel).

when executing

//Actual strings substituted
git.clone({
    username: "Name",
    password: "Pass",
    url: "http://localhost:8000/Path/Path.git",
    dir: "/Path/Path"
});

The git server is Gogs and CORS is set up there. The http headers sent and received are below:

Response headers (441 B)
Access-Control-Allow-Headers:   Content-Type, Authorization
Access-Control-Allow-Origin:    http://localhost:8080
Access-Control-Max-Age:         3600
Content-Length:                 0
Date:                           Mon, 05 Nov 2018 16:39:32 GMT
Set-Cookie:                     lang=en-US; Path=/; Max-Age=2147483647
Set-Cookie:                     i_like_gogits=3998a94c1759e12f; Path=/; HttpOnly
Set-Cookie:                     _csrf=TXDUIIY-1eQjYbUr9PHNZgsV…v 2018 16:39:32 GMT; HttpOnly
Request headers (477 B)	
Accept:                         text/html,application/xhtml+xm…plication/xml;q=0.9,*/*;q=0.8
Accept-Encoding:            	gzip, deflate
Accept-Language:	        en-US,en;q=0.5
Access-Control-Request-Headers:	authorization,user-agent
Access-Control-Request-Method:	GET
Connection:	                keep-alive
DNT:	                        1
Host:	                        localhost:8000
Origin:	                        http://localhost:8080
User-Agent:	                Mozilla/5.0 (X11; Linux x86_64…) Gecko/20100101 Firefox/60.0

(Setting Access-Control-Allow-Origin to * in Gogs doesn’t change the error.)

What am I missing?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Works like a charm. Thank you and apologies for the late feedback.

@MoonCoral as a temporary fix, what happens if you do

process.browser = true

before you call isomorphic-git?