4 examples of 'axios access control allow origin' in JavaScript

Every line of 'axios access control allow origin' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
46get origin() {
47 return this.options.origin || '*';
48}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

33function crossOrigin(request) {
34
35 var requestUrl = Url.parse(Url(request));
36
37 return (requestUrl.protocol !== originUrl.protocol || requestUrl.host !== originUrl.host);
38}
22isOriginAllowed(origin){
23 let allowOrigins = this.config.allow_origin;
24 if (!allowOrigins) {
25 return true;
26 }
27 let info = url.parse(origin);
28 let hostname = info.hostname;
29 if (think.isString(allowOrigins)) {
30 return allowOrigins === hostname;
31 }else if (think.isArray(allowOrigins)) {
32 return allowOrigins.indexOf(hostname) > -1;
33 }else if (think.isFunction(allowOrigins)) {
34 return allowOrigins(hostname, info);
35 }
36 return false;
37}
132function requestOrigin (configuration) {
133 var host = configuration.host;
134 var app = configuration.app;
135 var streamName = configuration.stream1;
136 var port = serverSettings.httpport.toString();
137 var portURI = (port.length > 0 ? ':' + port : '');
138 var baseUrl = isSecure ? protocol + '://' + host : protocol + '://' + host + portURI;
139 var apiVersion = configuration.streamManagerAPI || '3.1';
140 var url = baseUrl + '/streammanager/api/' + apiVersion + '/event/' + app + '/' + streamName + '?action=broadcast';
141 return new Promise(function (resolve, reject) {
142 fetch(url)
143 .then(function (res) {
144 if (res.headers.get("content-type") &&
145 res.headers.get("content-type").toLowerCase().indexOf("application/json") >= 0) {
146 return res.json();
147 }
148 else {
149 throw new TypeError('Could not properly parse response.');
150 }
151 })
152 .then(function (json) {
153 resolve(json);
154 })
155 .catch(function (error) {
156 var jsonError = typeof error === 'string' ? error : JSON.stringify(error, null, 2)
157 console.error('[PublisherStreamManagerTest] :: Error - Could not request Origin IP from Stream Manager. ' + jsonError)
158 reject(error)
159 });
160 });
161}

Related snippets