Activities

maverickpravin

maverickpravin posted a new question

proxy-module •

How to path rewrite for nuxt application

I am creating a new custom e-commerce application. Currently my product catlog url :
https://example.com/cat-title/cat-id

How can I rewrite to the following?
https://example.com/cat-title/

shangxinbo

shangxinbo posted a new question

proxy-module •

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 upgrade listeners added. Use emitter.setMaxListeners() to increase limit

When I configure the proxy to exceed 10, node will throw an error. Like this:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 upgrade listeners added. Use emitter.setMaxListeners() to increase limit

This will make my memory leak

yaki4

yaki4 posted a new question

proxy-module •

Use store value as header

Hi i would like to use a store value with onProxyReq.
But it seems that nuxt context or store is unavailable in proxy. Any ideas how to do it ?
I've tried req.body but it's undefined.
proxy: {
'/graphql': {
target: 'https://beautifulapigraph.com',
onProxyReq: function (proxyReq, req, res, options) {
proxyReq.setHeader('X-VAL', storeBasedValue)
}
}
}

yaki4

yaki4 posted a new question

proxy-module •

Use store value as header

Hi i would like to use a store value with onProxyReq.
But it seems that nuxt context or store is unavailable in proxy. Any ideas how to do it ?
I've tried req.body but it's undefined.
proxy: {
'/graphql': {
target: 'https://beautifulapigraph.com',
onProxyReq: function (proxyReq, req, res, options) {
proxyReq.setHeader('X-VAL', storeBasedValue)
}
}
},

ricardogobbosouza

ricardogobbosouza posted a new feature request

proxy-module •

idea Run CircleCI on PRs, and commits

What problem does this feature solve?

Run CircleCI on PRs, and commits

ricardogobbosouza

ricardogobbosouza posted a new question

proxy-module •

Run CircleCI on PRs, and commits

Nothing to preview

appinteractive

appinteractive posted a new question

proxy-module •

onProxyReq?

How can I use the onProxyReq or what is the best way to alter the header based on a value on the appobject?

chenyeah

chenyeah posted a new question

proxy-module •

XMLHttpRequest at 'http://localhost:3000/api' from origin 'http://127.0.0.1:3000' has been blocked

Access address http://127.0.0.1:3000 have some problems

proxy: {
    "/api": {
      target: "http://127.0.0.1:8080",
      pathRewrite: {
        "^/api": "/"
      }
    }
  }
this.$axios.$post("/api", {
      firstName: "Fred",
      lastName: "Flintstone"
    });

image

But address http://localhost:3000 have no problems

mtskf

mtskf posted a new question

proxy-module •

Caching

Is there any way to set cache on the proxy?
I'd appreciate if you could advise. Thanks :)

Anima-t3d

Anima-t3d posted a new question

proxy-module •

Proxy not working for server side calls?

I'm using proxy in nuxtServerInit and asyncData, but it does not seem to proxy the request properly? Everywhere else the proxy works just fine.

Currently using a workaround: Not use proxy for the base api, then only do the base api requests in nuxtServerInit and asyncData (e.g. the login and authentication. Specific api e.g. for task microservice api will be called elsewhere).

Is there something I am missing?

enjoyZhou

enjoyZhou posted a new question

proxy-module •

Proxy page will JavaScript heap out of memory

The first visit page will be successful, but this bug will occur when refreshing the page.
If the proxy's page size is too large, it will out of memory.

code:

// vue code
<iframe frameborder="0" width="100%" height="100%"
   src="/test/page"
   id="aFrame"></iframe>

// nuxt.config.js code
proxy: [
  ['/test/page', { target: 'http://github.com/nuxt-community/proxy-module', },],
  ],

err:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
zajca

zajca posted a new question

proxy-module •

POST requests with payload are not send to endpoint

I run into this problem.

When I have proxy set like this:

  proxy: {
    '/api/':{ target: process.env.API_URL, pathRewrite: {'^/api/': ''}, logLevel: 'debug' }
  },
  axios: {
    proxy: true
  },

when I send post to url is processed by backed just fine
this.$axios.$post('/api/non-existing-url') -> 404

But when i set payload like this:

      this.$axios.$post('/jh-api/non-existing-url', {
        form': {}
      })
->
Request failed with status code 504
✖ error nuxt › proxy › [HPM] Error occurred while trying to proxy request non-existing-url from localhost:3000 to http://127.0.0.1:8082 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)

proxy-module: 1.3.1
nuxtjs/axios: 5.3.4
nuxt: 2.2.0

tw666

tw666 posted a new question

proxy-module •

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 •

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 •

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 •

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 •

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 •

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 •

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 •

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