🎨 跨域配置

pull/56/head
ruibaby 2018-11-12 15:52:28 +08:00
parent 9634af938f
commit 3709d0fdb5
12 changed files with 23 additions and 25 deletions

View File

@ -98,7 +98,7 @@ public class MvcConfig implements WebMvcConfigurer {
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
registry.addMapping("/api/**")
.allowCredentials(true)
.allowedHeaders("*")
.allowedOrigins("*")

View File

@ -5,6 +5,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -19,6 +20,7 @@ import java.util.List;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/archives")
public class ApiArchivesController {

View File

@ -5,10 +5,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -20,6 +17,7 @@ import java.util.List;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/categories")
public class ApiCategoryController {

View File

@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.api;
import cc.ryanc.halo.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/comments")
public class ApiCommentController {

View File

@ -5,10 +5,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.GalleryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@ -21,6 +18,7 @@ import java.util.Optional;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/galleries")
public class ApiGalleryController {

View File

@ -5,6 +5,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -19,6 +20,7 @@ import java.util.List;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/links")
public class ApiLinkController {

View File

@ -5,6 +5,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -19,6 +20,7 @@ import java.util.List;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/menus")
public class ApiMenuController {

View File

@ -5,10 +5,7 @@ import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.OptionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@ -20,6 +17,7 @@ import java.util.Map;
* @author : RYAN0UP
* @date : 2018/7/19
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/options")
public class ApiOptionController {

View File

@ -6,10 +6,7 @@ import cc.ryanc.halo.model.enums.PostTypeEnum;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* <pre>
@ -19,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/pages")
public class ApiPageController {

View File

@ -14,10 +14,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -29,6 +26,7 @@ import java.util.List;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/posts")
public class ApiPostController {

View File

@ -5,10 +5,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -20,6 +17,7 @@ import java.util.List;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/tags")
public class ApiTagController {

View File

@ -5,6 +5,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.model.enums.ResponseStatusEnum;
import cc.ryanc.halo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author : RYAN0UP
* @date : 2018/6/6
*/
@CrossOrigin
@RestController
@RequestMapping(value = "/api/user")
public class ApiUserController {