How to properly configure Browsersync for a proxy server
I am struggling with proper Browsercync configuration (and maybe some middleware?).
My config is like:
local.example.com
its local address is configured via /etc/hosts
.
devel.example.com
It is our company that develops the environment (backend).
staging.example.com
it is our intermediate environment for our company.
As a UI developer, I want to use my local code, but I am working from one of the backend systems.
I am using gulp
to build my project etc. He also has the task of launching browser-sync
and monitoring file changes. But of course there are now issues with cookie domains coming from the backend. The CSRF corn domain is set by the browser to the backend being used.
I tried:
-
To use
http-proxy-middleware
configuration middleware :server: { baseDir: './build', middleware: [ proxyMiddleware('/api', { target: 'http://devel.example.com', changeOrigin: true, }) ] ]
But the problem I have is that it does the opaque redirects that are visible in the browser console. I thought it would work like this: the proxy will mask these requests in the browser, think that all requests and responses are coming from
local.example.com
. But it doesn't seem to work (or maybe I didn't configure it well).Also the big problem with this solution is that it somehow changes my HTTP requests
POST
toGET
(WTF ?!). -
Use build function in
browser-sync
proxy
. I've used an optionproxy
with an option in a lot of tutorialsserver
, but it doesn't seem to work anymore. So I tried to use it with theserveStatic
following:serveStatic: ['./build'], proxy: { target: 'devel.example.com', cookies: { stripDomain: false } }
But that doesn't work at all ...
I would really like some help with this topic.
thank
source to share
No one has answered this question yet
Check out similar questions: