Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

To disable server-to-server and REST tools like Postman to access our API - Remove !origin from your if statement.

var whitelist = ['http://example.com']
var corsOptions = {
  origin: function (origin, callback) {
    if (whitelist.indexOf(origin) !== -1) {
      callback(null, true)
    } else {
      callback(new Error('Not allowed by CORS'))
    }
  }
}

app.use(cors(corsOptions));
Comment

PREVIOUS NEXT
Code Example
Javascript :: How can I use a regex variable in a query for MongoDB 
Javascript :: object with key as individual choice and values as the second choice 
Javascript :: role based authentication in node js mongodb 
Javascript :: imleç 
Javascript :: JSX expression with JS template literals 
Javascript :: && in javascript new 
Javascript :: javascript border textbox 
Javascript :: nodejs createwriteStream file image broken 
Javascript :: palindromes array number 
Javascript :: regex placa de carro 
Javascript :: How to Define a Function using Function Declaration in javascript 
Javascript :: how to get faQuoteLeft fontawosome in react 
Javascript :: jquery init dropdown 
Javascript :: javascript add content to array 
Javascript :: pushReplacement Method 
Javascript :: javascript asynchronous 
Javascript :: https://graph.instagram.com/14.0/17841450694979740 
Javascript :: Changing Prototype 
Javascript :: react native tinder 
Javascript :: convert snake case to camelcase javascript recursive 
Javascript :: populate strapi v4 
Javascript :: delete all document fragments js 
Javascript :: uninstall spicetify 
Javascript :: OwlCarousel not working after build react js 
Javascript :: input change angular event 
Javascript :: javascript hover event listener 
Javascript :: swift urlsession remote json 
Javascript :: transform js to typescript 
Javascript :: zustand stores manage loading state 
Javascript :: Plumsail - DataTable Populating Dropdown 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =