简体   繁体   中英

Firebase CORS, whitelist IP ranges

I need to whitelist two IP ranges to access my firebase cloud functions, how that can be achieved? I am pretty sure that should be a way to define them here:

const cors = require('cors')({
    origin: true
});

But couldn't find anything on Google with this syntax

Per the configuration docs for the npm cors package , you can use an array as the origin value:

origin: ["http://example1.com", /\.example2\.com$/]

Each element in the array can either be a String or a RegExp .

Or you can just use a single RegExp as the value:

origin: /example\.com$/

I need to whitelist two IP ranges

Since the values specified in the origin option are matched against the value of the Origin request header the browser sends, if the Origin values sent contain IP addresses instead of hostnames, then specifying an IP-address RegExp in the origin option should work.

But if the Origin values sent in requests instead contain hostnames, then you'll need to either specify an array of hostname String s in the Origin value, or else a RegExp they'll all match.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM