Use api subdomain for requests to GHE.com hosts#19312
Conversation
| * http://github.mycompany.com -> http://github.mycompany.com/api/v3 | ||
| */ | ||
| export function getEnterpriseAPIURL(endpoint: string): string { | ||
| if (isGHE(endpoint)) { |
There was a problem hiding this comment.
Is the (legitimate) GHES case covered here? The path prefix is still used in GHES, but that's the only place where it's allowed.
Basically anything in dotcom and anything with a .ghe.com domain should use the api. subdomain.
There was a problem hiding this comment.
I think that's correct: https://github.com/desktop/desktop/blob/45f5c1e37de62da0c707b2ce246c92b34069ab5c/app/src/lib/endpoint-capabilities.ts/#L61-L63
/** Whether or not the given endpoint URI is under the ghe.com domain */
export const isGHE = (ep: string) => new URL(ep).hostname.endsWith('.ghe.com')I tested it and works as you describe. dotcom and .ghe.com requests use the api. subdomain while the rest still use /api/v3.
The only thing I've noticed is that existing logged-in users of .ghe.com domains will still use /api/v3 because we persist that base URL for users, and therefore those would need to be migrated:
[
{
"login": "sergiou87",
"endpoint": "https://api.github.com",
...
},
{
"login": "sergiou87",
"endpoint": "https://whatever.ghe.com/api/v3",
...
}
]We will take care of that in a different PR, but I will keep you posted!
There was a problem hiding this comment.
Got it, thanks for the confirmation!
sergiou87
left a comment
There was a problem hiding this comment.
Works as expected! The only exception is logged-in users of .ghe.com domains will still go through the /api/v3 route because the endpoint is persisted for those users and needs to be migrated.
Closes https://github.com/github/desktop/issues/867
Description
ghe.com hosts prefer the use of api.*.ghe.com rather than the GHES format of *.ghe.com/api/v3
Screenshots
Release notes
Notes: