updated cors-proxy to use given env variables
This commit is contained in:
260
.gitignore
vendored
260
.gitignore
vendored
@@ -1,14 +1,250 @@
|
||||
/.yarn/*
|
||||
!/.yarn/patches
|
||||
!/.yarn/plugins
|
||||
!/.yarn/releases
|
||||
!/.yarn/sdks
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/yarn,node,webstorm+all
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=yarn,node,webstorm+all
|
||||
|
||||
# Swap the comments on the following lines if you don't wish to use zero-installs
|
||||
# Documentation here: https://yarnpkg.com/features/zero-installs
|
||||
!/.yarn/cache
|
||||
#/.pnp.*
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### WebStorm+all ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### WebStorm+all Patch ###
|
||||
# Ignore everything but code style settings and run configurations
|
||||
# that are supposed to be shared within teams.
|
||||
|
||||
.idea/*
|
||||
|
||||
!.idea/codeStyles
|
||||
!.idea/runConfigurations
|
||||
|
||||
### yarn ###
|
||||
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
|
||||
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# if you are NOT using Zero-installs, then:
|
||||
# comment the following lines
|
||||
#!.yarn/cache
|
||||
|
||||
# and uncomment the following lines
|
||||
.pnp.*
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/yarn,node,webstorm+all
|
||||
|
||||
.idea/
|
||||
**/.idea/
|
||||
**/.idea/**
|
||||
|
363
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
363
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
5
.yarnrc.yml
Normal file
5
.yarnrc.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
@@ -1,27 +0,0 @@
|
||||
const cors_proxy = require('cors-anywhere')
|
||||
|
||||
const host = 'localhost'
|
||||
const port = 1337
|
||||
|
||||
cors_proxy
|
||||
.createServer({
|
||||
originWhitelist: [],
|
||||
requireHeader: ['origin', 'x-requested-with'],
|
||||
removeHeaders: [
|
||||
'cookie',
|
||||
'cookie2',
|
||||
'x-request-start',
|
||||
'x-request-id',
|
||||
'via',
|
||||
'connect-time',
|
||||
'total-route-time',
|
||||
],
|
||||
redirectSameOrigin: true,
|
||||
httpProxyOptions: {
|
||||
// Do not add X-Forwarded-For, etc. headers, because Heroku already adds it.
|
||||
xfwd: false,
|
||||
},
|
||||
})
|
||||
.listen(port, host, () => {
|
||||
console.log(`Running CORS Anywhere on 'http://${host}:${port}/'`)
|
||||
})
|
39
index.mjs
Normal file
39
index.mjs
Normal file
@@ -0,0 +1,39 @@
|
||||
import cors_proxy from 'cors-anywhere'
|
||||
import {env} from 'process'
|
||||
|
||||
let HOST = env.HOST || 'localhost'
|
||||
let PORT = env.PORT || 1337
|
||||
let USER = env.USER || ''
|
||||
let PW = env.PW || ''
|
||||
|
||||
const token = USER !== "" && PW !== ""
|
||||
? btoa(unescape(encodeURIComponent(USER + ':' + PW)))
|
||||
: ""
|
||||
|
||||
const headers = {}
|
||||
if (token !== "")
|
||||
headers.Authorization = `Basic ${token}`
|
||||
|
||||
cors_proxy
|
||||
.createServer({
|
||||
originWhitelist: [], // allow all origins
|
||||
requireHeader: ['origin', 'x-requested-with'],
|
||||
setHeaders: headers,
|
||||
removeHeaders: [
|
||||
'cookie',
|
||||
'cookie2',
|
||||
'x-request-start',
|
||||
'x-request-id',
|
||||
'via',
|
||||
'connect-time',
|
||||
'total-route-time',
|
||||
],
|
||||
redirectSameOrigin: true,
|
||||
httpProxyOptions: {
|
||||
// Do not add X-Forwarded-For, etc. headers, because Heroku already adds it.
|
||||
xfwd: false,
|
||||
},
|
||||
})
|
||||
.listen(PORT, HOST, () => {
|
||||
console.log(`Running CORS Anywhere on 'http://${HOST}:${PORT}/'`)
|
||||
})
|
@@ -2,7 +2,7 @@
|
||||
"name": "_cors-proxy",
|
||||
"packageManager": "yarn@3.0.2",
|
||||
"scripts": {
|
||||
"cors": "node cors_proxy.js"
|
||||
"cors": "node index.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"cors-anywhere": "^0.4.4"
|
||||
|
Reference in New Issue
Block a user