移动端
| common | ||
| components | ||
| nativeplugins | ||
| pages | ||
| README_files | ||
| static | ||
| store | ||
| unpackage/res/icons | ||
| utils | ||
| uview-ui | ||
| .gitignore | ||
| androidPrivacy.json | ||
| App.vue | ||
| h5.html | ||
| main.js | ||
| manifest.json | ||
| package-lock.json | ||
| package.json | ||
| pages.json | ||
| project.config.json | ||
| README.md | ||
| uni.scss | ||
| vue.config.js | ||
MOM 移动端
下载 HBuilderX
https://www.dcloud.io/hbuilderx.html
下载微信开发者工具
https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
配置开发者工具
HBuilderX
后台配置跨域
网关跨域配置
nacos 配置如下配置即可
- nacos mom-gateway-dev.yml
spring:
cloud:
gateway:
globalcors:
corsConfigurations:
'[/**]':
allowedOriginPatterns: '*' #注意这个设置只对 spring boot 2.4+ 有效, mom v4.0+ ,低版本 使用 allowedOrigins: "*"
allowed-methods: '*'
allowed-headers: '*'
allow-credentials: true
exposedHeaders: 'Content-Disposition,Content-Type,Cache-Control'
以上配置可作为开发环境使用,生成环境建议你根据实际情况修改(请先理解 CORS,并参考 org.springframework.cloud.gateway.config.GlobalCorsProperties) 跨域时会产生预检请求(Pre-Flight Request),这样就会对你的服务器产生额外的网络请求。如果可以通过部署手段解决跨域,则可以关闭跨域支持,方法是把以上配置信息清理掉。
测试
为了演示跨域支持效果,可以修改一下前端项目(momx-ui)的登录代码
- login.js
export const loginByUsername = (username, password, code, randomStr) => {
const grant_type = 'password';
return request({
// 原来的API接口地址
//url: '/auth/oauth/token',
// 为了触发跨域,直接修改为网关的url,这里的IP需要改成你自己的,要用真实IP
url: 'http://127.0.0.1:9999/auth/oauth/token',
headers: {
isToken: false,
Authorization: 'Basic cGlnOnBpZw==',
},
method: 'post',
params: { username, password, randomStr, code, grant_type, scope },
});
};



