In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of what the cross-domain processing method commonly used in vue is, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this article on cross-domain processing commonly used in vue. Let's take a look.
Set up express proxy request
In vue-cli-based projects, proxies are set in the development environment configuration (config/dev.env.js) to redirect all requests starting with / apidomain to the target interface through the express server started by npm run dev
ProxyTable: {'/ apidomain': {target:' http://localhost:prot',// or ip or domain name. ChangeOrigin:true, pathRewrite: {'^ / apidomain':'}
To access h6 on the local area network through IP, add the host parameter when you start the development server
That is, the dev command for package.json is configured as follows
"dev": "webpack-dev-server-inline-progress-config build/webpack.dev.conf.js-host 0.0.0.0"
Turn off chrome security policy to achieve cross-domain
Create a new bat file in windows and paste the following command to open it in this mode
Cd "C:\ Program Files (x86)\ Google\ Chrome\ Application" chrome.exe-disable-web-security-user-data-dir=c:/CorsUserData
Cross-domain setting of CORS on asp.net core server
In the actual setting, due to the pre-check (OPTIONS) request caused by adding the header parameter to the h6 side, the general parameter was modified to the query parameter after reading the above article.
1. Add cors service
Public void ConfigureServices (IServiceCollection services) {/ / define one or more named CORS policies if there is only part of the interface, and set cross-domain details through feature tags by the policy selected by name at run time, see document services.AddCors ();}
two。 Enable middleware
/ / read the cross-domain domain name CorsOrigins set in the configuration file to set for an array ["*"] will allow all var origins = Configuration.GetSection ("CorsOrigins") .GetChildren () .Select (s = > s.Value) .ToArray (); app.UseCors (e = > {e.WithOrigins (origins) .AllowAnyHeader () .AllowAnyMethod () .AllowCredentials ()); / / acquisition of Configuration objects in Startup file public IConfiguration Configuration {get } public Startup () {var builder = new ConfigurationBuilder () / /... AddJsonFile ($"appsettings.json"); Configuration = builder.Build ();}
JSONP
JSONP supports only GET requests, and CORS supports all types of HTTP requests. JSONP has the advantage of supporting older browsers and the ability to request data from websites that do not support CORS.
This is the end of the article on "what are the common cross-domain processing methods in vue?" Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "what is the common cross-domain processing method in vue". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.