Skip to content

Instantly share code, notes, and snippets.

View arthurbergmz's full-sized avatar
🔮
curiosity keeps leading us down new paths

Arthur A. Bergamaschi arthurbergmz

🔮
curiosity keeps leading us down new paths
View GitHub Profile
@arthurbergmz
arthurbergmz / cors.md
Created February 23, 2022 13:49 — forked from liamgriffiths/cors.md
How CORS works

Guide to CORS

CORS (cross origin resource sharing) is a mechanism to allow client web applications make HTTP requests to other domains. For example if you load a site from http://domainA.com and want to make a request (via xhr or img src, etc) to http://domainB.com without using CORS your web browser will try to protect you by blocking the response from the other server. This is because browsers restrict responses coming from other domains via the Same-Origin-Policy.

CORS allows the browser to use reponses from other domains. This is done by including a Access-Control headers in the server responses telling the browser that requests it is making is OK and safe to use the response.

Header Description
Access-Control-Allow-Origin: Allow requests from `` to access t
@arthurbergmz
arthurbergmz / gist:87e0171fba17b730b1f09f0251356e0e
Created January 3, 2020 05:01 — forked from taylorhughes/gist:4dc50b2fe674c0a84cc6
Update Facebook token in iOS client from existing server-side cached token
[self.apiClient retrieveConnectedServicesWithSuccessBlock:^(NSDictionary *services) {
NSArray *facebookTokens = services[@"facebook"];
if (facebookTokens.count == 0) {
return;
}
NSDictionary *mostRecentFacebookTokenDict = facebookTokens[0];
NSNumber *refreshTimeNumber = mostRecentFacebookTokenDict[@"refreshTime"];
NSDate *refreshDate = [NSDate dateWithTimeIntervalSince1970:[refreshTimeNumber doubleValue]];