前端的/users/code改成post方法,传递json改成正确格式

pull/2/head
2991692032 4 months ago
parent 126c1e9151
commit 4908ad6408

@ -186,10 +186,8 @@ const password = computed(()=>register_password.value ?? login_password.value)
const vericode = computed(()=>register_vericode.value ?? login_vericode.value)
//
async function emailcode(){
const res = await request.get('/users/code', {
data:{
const res = await request.post('/users/code', {
email: email.value
}
})
console.log("success")
@ -198,10 +196,8 @@ async function emailcode(){
//
async function testcode() {
const res = await request.post('/users/login/code', {
data: {
email: email.value,
code: vericode.value
}
})
return res.data;
@ -209,7 +205,6 @@ async function testcode() {
async function register(){
const res = await request.post('/users/register', {
data:{
email: email.value,
password: password.value,
username:null,
@ -218,17 +213,14 @@ async function register(){
department:null,
major:null,
grade:null,
}
})
return res.data;
}
async function login(){
const res = await request.post('/users/login', {
data:{
email: email.value,
password: password.value
}
})
return res.data;
}

@ -3,6 +3,7 @@ package com.unilife.config;
import com.unilife.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -26,4 +27,14 @@ public class WebMvcConfig implements WebMvcConfigurer {
);
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*") // 允许所有来源,生产环境建议限制为特定域名
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(3600);
}
}

@ -1,5 +1,5 @@
server:
port: 8084
port: 8080
spring:
datasource:
url: jdbc:mysql://localhost:3306/UniLife?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8

Loading…
Cancel
Save