The new version of Chrome browser settings allows cross-domain implementation

The new version of Chrome browser settings allows cross-domain implementation

Preface

Currently, the front-end solves cross-domain problems mainly through the configuration of webpack's devServer. But sometimes devServer is not configured in the development environment, and cross-domain is not set up in the backend. When debugging code locally in a project with separated front-end and back-end, cross-domain issues are often encountered. This article is mainly to supplement the previous article on cross-domain browser access solutions. Because the last setting of this article is about Chrome, the current setting does not work, so I updated the article and corrected it.

Solution to the problem that --disable-web-security does not work

The previous article provided the setting methods of --disable-web-security for Windows, Mac, Linux, etc., but the new version of Chrome has upgraded its security policy, and this opening method or the previous setting method is invalid. So how to solve it?

1. To set cross-domain, right-click the Chrome shortcut, click 'Properties', 'Shortcut', press the space at the end of the 'Target' path, and then add the following code:

--args --disable-web-security --user-data-dir=D:\HaoroomsChromeUserData

or

--disable-web-security --user-data-dir=D:\HaoroomsChromeUserData

D:\HaoroomsChromeUserData is a folder I found randomly. You can configure it at will. If you don’t write it like this, the new version of the browser may have problems with the settings not taking effect.

This method is equivalent to the user creating a private Chrome browser on his own computer, and the settings and configurations in it are all private settings. At this time, find the chrome installation source directory and open chrome.exe. You will find that all the bookmarks, options, etc. configured in the private chrome are not in this chrome.

Note: If you want to delete D:\HaoroomsChromeUserData, be sure to back up your bookmarks, account passwords, etc. first. Once deleted, it is equivalent to uninstalling the private Chrome in the personal computer, and no data will be retained

2. After the setting is successful, open the browser again and there will be a prompt:

"You are using an unsupported command line flag: --disable-web-security, which may reduce stability and security"

At this point, normal users can perform cross-domain access, such as local front-end projects, direct connection tests, or online environment interfaces (the premise is that the target environment has been logged in in the current browser and the cookies, session, and other information of the current account already exist)

3. Some users still cannot access the system. In this case, a yellow text will be displayed in the console.

'...Specify SameSite=None and Secure if the cookie should be sent in cross-site...'

At this time, the browser still restricts cross-domain access to cookies, so some people's computers still cannot use cross-domain.

Solution:

Enter in the address bar:

chrome://flags

Search again:

SameSite by default cookies

Find 'SameSite by default cookies' and 'Cookies without SameSite must be secure'. There is a drop-down box behind it. Select 'disabled' for both options. The browser will prompt a red message: 'Warning: You are about to use an experimental feature! '

Choose to ignore the warning. At this time, the browser is the D:\HaoroomsChromeUserData we created locally. Click the Relaunch button in the lower right corner, the browser will automatically restart and keep all currently opened pages.

Note: This mode is used for joint debugging. If you visit other shopping websites, it is recommended to use the chrome.exe in the chrome.exe installation source directory to avoid unnecessary trouble.

Other systems:

Mac is the same as Linux. The original command line does not work. A folder for storing data is also specified to achieve the cross-domain effect.

Other solutions

A temporary solution can be achieved by using a chrome plug-in.

Search for Chrome extensions

Allow-Control-Allow-Origin: *

After installing the plugin, read their documentation and set the address to be accessed across domains.

This is the end of this article about how to set up the new version of Chrome browser to allow cross-domain implementation. For more relevant content about Chrome allowing cross-domain, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  Detailed introduction to linux host name configuration

>>:  A simple way to put HTML footer at the bottom of the page

Recommend

In-depth discussion on auto-increment primary keys in MySQL

Table of contents Features Preservation strategy ...

jQuery uses the canvas tag to draw the verification code

The <canvas> element is designed for client...

Nginx's practical method for solving cross-domain problems

Separate the front and back ends and use nginx to...

Basic notes on html and css (must read for front-end)

When I first came into contact with HTML, I alway...

Use standard dl, dt, dd tags to discard table lists

Now, more and more front-end developers are starti...

How to install PostgreSQL and PostGIS using yum on CentOS7

1. Update the yum source The PostgreSQL version o...

How to use CSS to pull down a small image to view a large image and information

Today I will talk about a CSS special effect of h...

Implementation example of Nginx+Tomcat load balancing cluster

Table of contents introduction 1. Case Overview 2...

Sample code on how to implement page caching in vue mobile project

background On mobile devices, caching between pag...

MySQL Index Optimization Explained

In daily work, we sometimes run slow queries to r...

Analyzing the troublesome Aborted warning in MySQL through case studies

This article mainly introduces the relevant conte...

How to turn local variables into global variables in JavaScript

First we need to know the self-calling of the fun...

An Uncommon Error and Solution for SQL Server Full Backup

1. Error details Once when manually performing a ...

HTML Several Special Dividing Line Effects

1. Basic lines 2. Special effects (the effects ar...

Install OpenSSL on Windows and use OpenSSL to generate public and private keys

1. OpenSSL official website Official download add...