Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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

how to disable the cors in spring boot

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		http.cors().and()...
	}
}
Comment

CORS with Spring Boot

@CrossOrigin
Comment

PREVIOUS NEXT
Code Example
Java :: java change frame border 
Java :: how to create search function in android studio 
Java :: java inner function 
Java :: android studio clear views of layout 
Java :: java file creation date 
Java :: arraylist in java 
Java :: what is delegation in java 
Java :: can a java class have more than 108 constructors 
Java :: resultset next method 
Java :: update in spring boot 
Java :: take a peice from array java 
Java :: input char arrayjava 
Java :: java resultset to table 
Java :: java hashmap increase value by 1 
Java :: update java windows 
Java :: how to assign null to a variable in Java 
Java :: merge without extra space 
Java :: java string replace 
Java :: sending a excel in an attachment in email java 
Java :: math class in java 
Java :: convert string to boolean java 
Java :: java linked list swap elements 
Java :: java casting to int 
Java :: java how to create subclass 
Java :: generate hash in java 
Java :: java servlet life cycle 
Java :: void * to int 
Java :: method overriding in java 
Java :: creating a properties object using a file 
Java :: Permutations of array in Java 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =