JS cross-domain solution react configuration reverse proxy

JS cross-domain solution react configuration reverse proxy

Cross-domain solutions

jsonp (simulate get)

CORS (Cross-Origin Resource Sharing)

acting

iframe

postMessage

window.name

WebSocket

React's proxy implements cross-domain

Configure in src/setupProxy.js file and install http-proxy-middleware, proxy middleware module through npm

Create src/setupProxy.js

Installing the Module

npm i -S http-proxy-middleware

const { createProxyMiddleware: proxy } = require('http-proxy-middleware')
module.exports = app => {
  app.use('/api', proxy({
    target: 'http://localhost',
    changeOrigin: true,
    pathRewrite: {
      '^/api': ''
    }
  }))
} 

The above is the details of JS cross-domain solution react configuration reverse proxy. For more information about react configuration reverse proxy, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • React build post-packaging and release summary
  • How to implement cors cross-domain request of fetch in react
  • Tutorial on how to configure React static pages with nginx
  • JS cross-domain solution: using CORS to achieve cross-domain

<<:  How to implement line breaks in textarea text input area

>>:  25 div+css programming tips and tricks

Recommend

How to use wangEditor in vue and how to get focus by echoing data

Rich text editors are often used when doing backg...

Using streaming queries in MySQL to avoid data OOM

Table of contents 1. Introduction 2. JDBC impleme...

Detailed explanation of Vue's monitoring method case

Monitoring method in Vue watch Notice Name: You s...

Vue.js application performance optimization analysis + solution

Table of contents 1. Introduction 2. Why do we ne...

2017 latest version of windows installation mysql tutorial

1. First, download the latest version of MySQL fr...

A brief discussion on the correct approach to MySQL table space recovery

Table of contents Preliminary Notes Problem Repro...

Detailed explanation of scheduled tasks and delayed tasks under Linux

at at + time at 17:23 at> touch /mnt/file{1..9...

The whole process of installing mysql5.7.22 under ARM64 architecture

MySQL download address: https://obs.cn-north-4.my...

How to build a Vue3 desktop application

In this article, we will look at how to develop a...

CSS3 realizes various graphic effects of small arrows

It’s great to use CSS to realize various graphics...

Solution to css3 transform transition jitter problem

transform: scale(); Scaling will cause jitter in ...