M
M
Mikhail2020-06-13 22:52:02
Node.js
Mikhail, 2020-06-13 22:52:02

Why in production in the console requests as localhost:3000/api/list and not through the domain?

It costs nuxt js + express
There is an internal backing with the database and ORM sequelize
The first time when updating the page everything is fine, it is done By action, a request is made via axios get('/api/list') to the controller And in the controller I already get it through ORM from the database But if you go to another page, and then back, then there is an error in the console
store.dispatch('washers/list')

http://localhost:3000/api/list net::ERR_CONNECTION_REFUSED

This is understandable, because the client does not have a localhost + port 3000
server in
the browser works as proxy_pass http://127.0.0.1:3000; I tried to prescribe in the nuxt config
axios: {
    proxy: true
  },
proxy: {
    '/api/': { target: 'https://mydomain.ru/', pathRewrite: { '^/api/': '' }, changeOrigin: true }
  },

But in the browser everything is fine
http://localhost:3000/api/list net::ERR_CONNECTION_REFUSED

Where to dig and what to change and where?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
szanislo, 2020-06-13
@Sergo94Min

It is worth checking that relative paths are specified everywhere, and not absolute ones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question