Repository proxy-module

tw666

tw666 posted a new question

proxy-module • 4 days ago

How to use exclusion function?

I want to exclude a url in the proxy.

There is such a writing in chimurai/http-proxy-middleware.

proxy(['/api/**', '!**/bad.json'], {...}) exclusion

How to write in proxy-module?

Thinks!

tw666

tw666 posted a new question

proxy-module • 4 days ago

How to use exclusion function?

I want to exclude a url in the proxy.

There is such a writing in chimurai/http-proxy-middleware.

proxy(['/api/**', '!**/bad.json'], {...}) exclusion

How to write in proxy-module?

Thinks!

stefandevo

stefandevo posted a new question

proxy-module • 2 months ago

Is there a way to use environment var for the proxy http?

Would it be possible to use a kind of parameter, environment variable in case of different proxy locations depending on run dev

'/json': 'http://localhost:5000/'

or run beta?

'/json': 'http://beta.application.com/'
msprogramando

msprogramando posted a new question

proxy-module • 4 months ago

504 | Error occurred while trying to proxy request (ECONNREFUSED) | docker | jwilder | nuxt

Hi,
I am using two docker containers, one for vue and the other for api requests. Another proxy container (jwilder) is sitting in front.
Both Images expose their ports in the Dockerfile.

To get an impression, this is my docker-compose file:
services:
# Nodejs + Express
server:
image: testbenchapp:test build: context: ./server/ command: /usr/app/nodemodules/.bin/nodemon src/app.js
volumes:
- ./server/:/usr/app
- nodemodulesserver:/usr/app/nodemodules ports: - "8081:8081" # envfile: ./server/.env # TODO - uncomment this to auto-load your .env file!
environment:
NODEENV: development CHOKIDARUSEPOLLING: "true"
VIRTUALHOST: api.testbench.de.docker VIRTUALPORT: 8081

# Vue
client:
image: testbenchclient:test build: context: ./client/ dockerfile: client.dockerfile command: npm run dev volumes: - ./client/:/usr/app - nodemodulesclient:/usr/app/nodemodules
dependson: - server environment: VIRTUALHOST: public.testbench.de.docker
VIRTUAL_PORT: 3000

volumes:
dbdata: nodemodulesclient: nodemodules_server:

networks:
default:
external:
name: nginx-proxy

Nodejs + Express package.json

{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"build": "webpack --mode production",
"start": "./nodemodules/nodemon/bin/nodemon.js src/index.js --exec 'npm run lint & node'", "lint": "./nodemodules/.bin/eslint */.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"cors": "^2.8.4",
"express": "^4.16.2",
"joi": "^13.1.2",
"jsonwebtoken": "^8.1.1",
"lodash-node": "^3.10.2",
"morgan": "^1.9.0",
"mysql2": "^1.5.2",
"sequelize": "^4.34.1"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"eslint": "^4.18.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"nodemon": "^1.15.1",
"webpack": "^4.10.2",
"webpack-cli": "^2.1.4",
"webpack-node-externals": "^1.7.2"
}
}

Vue

{
"name": "testbench",
"version": "1.0.0",
"description": "Nuxt.js project",
"author": "martin",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint"
},
"dependencies": {
"@nuxtjs/axios": "^5.1.1",
"@nuxtjs/proxy": "^1.2.4",
"marked": "^0.4.0",
"material-design-icons-iconfont": "^3.0.3",
"nuxt": "^1.0.0",
"storyblok-nuxt": "0.0.3",
"vuetify": "^1.0.19",
"vuex-persistedstate": "^2.5.1"
},
"devDependencies": {
"babel-eslint": "^8.2.1",
"css-loader": "^0.28.11",
"eslint": "^4.15.0",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-vue": "^4.0.0",
"node-sass": "^4.9.0",
"sass-loader": "^7.0.2",
"vue-loader": "^13.7.2"
}
}

some parts of my nuxt.config.js

modules: [
'@nuxtjs/axios',
'@nuxtjs/proxy'
],
axios: {
proxy: true,
logLevel: 'debug'
},
proxy: {
'/api': 'http://api.testbench.de.docker'
},

This is is the ajax call

        this.$axios.$post('/api/register/email', {
          name: this.name,
          email: this.email,
          password: this.password
        })
        .then(res => {
          console.log(res)
          this.$router.push('/')
        })
        .catch(e => {
          console.log(e.response.data.error)
        })

And this is the rout on the node / express.js container
module.exports = (app) => {

app.post('/api/register/email',
AuthenticationControllerPolicy.registerEmail,
AuthenticationController.registerEmail)

}

This is the error:
[NUXT:PROXY] [HPM] Error occurred while trying to proxy request /api/register/email from public.testbench.de.docker to http://api.testbench.de.docker (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Does anybody has an idea. I am already spending two days on this error :D

Bildschirmfoto 2018-06-17 um 08.17.12.png

japboy

japboy posted a new question

proxy-module • 4 months ago

How to log to stdout

logLevel options doesn't seem to affect. how can i log proxy?

axetroy

axetroy posted a new question

proxy-module • 5 months ago

Duplicate cookies

Normal Request Header

Request URL: http://localhost:6088/
Request Method: GET
Status Code: 200 OK
Remote Address: 127.0.0.1:6088
Referrer Policy: no-referrer-when-downgrade

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,zh-HK;q=0.7
Cache-Control: no-cache
Connection: keep-alive
Cookie: Authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI5YjBlNWUzZi0zMGU3LTRlOTItODhlMS1iMmJiNzJjYjk1YmMiLCJleHBpcmVkIjoxNTI4NDQxMjQ0LCJpYXQiOjE1MjgzNTQ4NDR9.cq8bNEdeo6rX4Ao56nKjpOZeDXlI9FZk5u7U_yxpvgg
DNT: 1
Host: localhost:6088
Pragma: no-cache
Referer: http://localhost:6088/repo/create
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36

Proxy Request Header

Request URL: http://localhost:6088/api/graphql
Request Method: POST
Status Code: 200 OK
Remote Address: 127.0.0.1:6088
Referrer Policy: no-referrer-when-downgrade

Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,zh-HK;q=0.7
Connection: keep-alive
Content-Length: 300
Content-Type: application/json;charset=UTF-8
Cookie: Authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIwYzkwMDAwYy05ZDIxLTRjNTctYTE4ZS1hMzAyYTAwZDg1ZmQiLCJleHBpcmVkIjoxNTI4MzU3MTE2LCJpYXQiOjE1MjgyNzA3MTZ9.MdPAlJVBlJR8faDw_VxVcE6zVLjIVH-YC6vSisnzBe0; Authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI5YjBlNWUzZi0zMGU3LTRlOTItODhlMS1iMmJiNzJjYjk1YmMiLCJleHBpcmVkIjoxNTI4NDQxMjQ0LCJpYXQiOjE1MjgzNTQ4NDR9.cq8bNEdeo6rX4Ao56nKjpOZeDXlI9FZk5u7U_yxpvgg
DNT: 1
Host: localhost:6088
Origin: http://localhost:6088
Referer: http://localhost:6088/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36

Look at the cookie Authorization=xxx

The normal request only sent once. the proxy send 2 same Authorization key.

and I even don't know how it comes.

It seen only occurs in [email protected], work in firefox and safari

samuells

samuells posted a new question

proxy-module • 7 months ago

How to setToken with axios-module for multiple API's

Hi,

I have 2 api, from which I need to get data. Both of them are using Bearer authentication token - but this token is different for each api. How can I set token to the axios, if I am using proxy to switch baseURL, but the token is set on the axios instance?

gorango

gorango posted a new question

proxy-module • 7 months ago

Proxy option "target" doesn't redirect to external URLs

The request that is generated when attempting to proxy to an external API redirects to localhost.

Reproduce with the following:

nuxt.config:

modules: [
    '@nuxtjs/axios',
    '@nuxtjs/proxy'
  ],
  axios: {
    proxy: {
      '/geo': {target: 'http://freegeoip.net/json', pathRewrite: {'^/geo': ''}}
    }
  }

component.vue:

export default {
  async created () {
    const location = await this.$axios.$get('/geo')
    console.log(location)
  }
}

Throws a 404 with the following request headers in the call:

Request URL: http://localhost:3000/json/
Request Method: GET
Status Code: 404 Not Found
japboy

japboy posted a new question

proxy-module • 8 months ago

Support HTTP/2 server

I need HTTP/2 server support

JesusCrow

JesusCrow posted a new question

proxy-module • 8 months ago

SPA & Static

This module seems to be incompatible with static and SPA modes (because only server calls are rewritten). I would like to get a confirmation for this statement, then we could do something like:

  1. Add disclaimer in README.md and during nuxt generate
  2. Add disclaimer in modules that use this module (like axios module?)
  3. Consider a way for this plugin to work for other modes (rewriting URL's during generating?)