Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

spring cors allow all origins

HomeController.java
@CrossOrigin(origins = "*", allowedHeaders = "*")
@Controller
public class HomeController 
{
  @GetMapping(path="/")
  public String homeInit(Model model) {
    return "home";
  }
}
Comment

spring enable cors

@Controller
@CrossOrigin(origins = "http://localhost:3000")
public class MyController {

}
Comment

how to enable cors request on springboot application

package com.example.restservicecors;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
public class RestServiceCorsApplication {

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

	@Bean
	public WebMvcConfigurer corsConfigurer() {
		return new WebMvcConfigurer() {
			@Override
			public void addCorsMappings(CorsRegistry registry) {
				registry.addMapping("/greeting-javaconfig").allowedOrigins("http://localhost:8080");
			}
		};
	}

}COPY
Comment

PREVIOUS NEXT
Code Example
Java :: default structure of java 
Java :: install java apt 
Java :: Cannot resolve class android.support.design.widget.AppBarLayout 
Java :: java hashmap entryset 
Java :: copy array in java 2d 
Java :: java remove empty lines from string 
Java :: how to write on top of equal sign in latex 
Java :: bukkit inventory set name 
Java :: string to double java exception 
Java :: Could not find any matches for com.transistorsoft:tsbackgroundfetch:+ as no versions of com.transistorsoft:tsbackgroundfetch are available. 
Java :: java random 6 digit number 
Java :: beans tag definition for spring frame work 
Java :: array to map java3 
Java :: from string to int android studio 
Java :: how to disable screen rotation android studio 
Java :: how to delete last char in string java 
Java :: moving text in textview android 
Java :: como utilizar random en java 
Java :: how to make an invisiblke button in swing 
Java :: java radnom 
Java :: javaee jsp convert int to string 
Java :: how to get the highest value in a list java 
Java :: convert object to map scala 
Java :: java windowlistener close window 
Java :: Integer i = new Integer(257); byte x = i.byteValue(); System.out.print(x); 
Java :: text before dot java 
Java :: java write string 
Java :: javafx event resize 
Java :: character classes in regex 
Java :: spring xml 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =