Skip to content

Instantly share code, notes, and snippets.

View felorodri's full-sized avatar

Julián Rodríguez felorodri

View GitHub Profile
const functions = require('firebase-functions');
const nodemailer = require("nodemailer");
// Configure the email transport using the default SMTP transport and a GMail account.
// For Gmail, enable these:
// 1. https://www.google.com/settings/security/lesssecureapps
// 2. https://accounts.google.com/DisplayUnlockCaptcha
// For other types of transports such as Sendgrid see https://nodemailer.com/transports/
// TODO: Configure the `gmail.email` and `gmail.password` Google Cloud environment variables executing at your firebase project folder the command "firebase functions:config:set gmail.email="[email protected]" gmail.password="your password here"".
gmailEmail = encodeURIComponent(functions.config().gmail.email);
gmailPassword = encodeURIComponent(functions.config().gmail.password);
@felorodri
felorodri / cors.md
Created March 15, 2019 01:34 — forked from jesperorb/cors.md
Handle CORS Client-side

Handle CORS Client-side

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.

Sources : MDN - HTTP Access Control | Wiki - CORS

CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:

Access-Control-Allow-Origin