码迷,mamicode.com
首页 > 编程语言 > 详细

springboot2.1.3 配置前后端跨域问题

时间:2019-11-13 01:09:48      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:gateway   reg   configure   port   spring   DDM   void   comm   ddc   

很简单,创建一个配置类即可,如下:

package com.app.gateway.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
	
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**")
					.allowedOrigins("*")
					.allowedHeaders("*")
					.allowedMethods("*")
					.maxAge(30 * 1000);
	}
	
}

 

springboot2.1.3 配置前后端跨域问题

标签:gateway   reg   configure   port   spring   DDM   void   comm   ddc   

原文地址:https://www.cnblogs.com/jimmyshan-study/p/11846239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!