Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umi-request请求后端不加密 #81

Open
resuper opened this issue Feb 11, 2022 · 1 comment
Open

umi-request请求后端不加密 #81

resuper opened this issue Feb 11, 2022 · 1 comment

Comments

@resuper
Copy link

resuper commented Feb 11, 2022

postman请求响应正常,umi-request请求不正常

前端代码

import request from 'umi-request';
request.post('/api/test/encryptTransmission/',{
      // aes 加密后的字符串
      // data:Encrypt(JSON.stringify(reqData)),
      // rsa 加密后的字符串
      // data:jsEncrypt.encrypt(JSON.stringify(reqData)),
      // json对象
      data:reqData,
      headers:{
        Accept:'*/*'
      }
    }).then((res)=>{
      console.log('1');
    })

后端代码
pom.xml

<dependency>
            <groupId>com.cxytiandi</groupId>
            <artifactId>monkey-api-encrypt-core</artifactId>
            <version>1.2.RELEASE</version>
        </dependency>

springboot主启动类

@SpringBootApplication
@MapperScan(basePackages = {"com.iwhalecloud.yn.portal.mapper"})
@EnableEncrypt
public class YnPortalServerApplication {

//    @Resource
//    private MyRsaEncryptAlgorithm myRsaEncryptAlgorithm;

    public static void main(String[] args) {
        SpringApplication.run(YnPortalServerApplication.class, args);
    }

}

TestController

@RestController
@RequestMapping("/test")
public class TestController {
    @RequestMapping("/hello")
    public Result hello() {
        return Result.buildFail("-440033", "服务器正常返回,但是返回的结果告知服务器或业务不对");
    }

    @Encrypt
    @PostMapping(path = "/encryptTransmission" ,consumes="application/json")
    public Result encryptTransmission(@RequestBody MyUserDetails myUserDetails) {
        return Result.buildSuccess(myUserDetails);
    }
}

测试结果
postman
image

前端项目
image

image

@yinjihuan
Copy link
Owner

前端项目的uri多了一个api,这个是后端项目的content-path吗?如果是的话你升级到1.2.2版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants