Skip to content

Instantly share code, notes, and snippets.

View vinaypuppal's full-sized avatar
🤓
Working from home

vínαч puppαl vinaypuppal

🤓
Working from home
  • @getperspective.ai
  • INDIA
  • 11:41 (UTC +05:30)
  • X @vinaypuppal
View GitHub Profile
@vinaypuppal
vinaypuppal / now-realias.js
Created September 6, 2016 11:38 — forked from remy/now-realias.js
Quick `now` re-alias script, if run inside the current project dir
#!/usr/bin/env node
const Now = require('now-client');
const now = Now(); // this looks like it detect the token from ~/.now.json or the env automatically
const pkg = require(process.cwd() + '/package.json');
now.getDeployments().then(res => {
const [latest, prev, ...rest] = res.filter(_ => _.name === pkg.name).sort((a, b) => b.created - a.created);
console.log(`getting alias for ${prev.uid} (${prev.url})`);
return now.getAliases(prev.uid).then(res => {

Source from this course: https://udacity.com/course/intro-to-ajax--ud110

What is CORS and why are we using it?

CORS works around a sometimes overly-strict browser policy(i.e same-origin policy) meant to protect servers from malicious requests. CORS is enabled on the server-side, so you won't generally need to worry about it for your code. You do need to know about it though, since some APIs support it, and some do not.

The same-origin policy was implemented by web browsers to prevent malicious scripts from untrusted domains from running on a website. In other words, it ensures sure that scripts from one website can't insert themselves into another.

For example, the same-origin policy keeps the bad guys’ JavaScript from somehow running on your bank’s website and stealing your information.

Over time, developers realized that this policy was too strict, and often got in the way of legitimate use-cases. There are many reasons to serve content from multiple domain origins, and so developers found a way

/* Made by ciara.io for Meteor Academy */
body {
color: #333;
font-family: sans-serif;
font-size: 115%;
line-height: 24px;
}
footer {