'How do I prevent RSocket from allowing cross origin in Spring Boot?

My Problem
I have a spring boot application that uses RSockets.
My spring boot app is running on port 8080, and my front-end (React.js) is running on port 3000.
The problem is that my front-end does not get blocked by cors policy.
This is a bit worrying, because I want other origins to be blocked by cors policy when I deploy the app at a later point in time.
I am guessing that I am somehow allowing all origins in my RSocket Configuration (see below).

My RSocket Configuration

package com.example.server.api.rsocket.config;
import org.springframework.boot.autoconfigure.rsocket.RSocketProperties;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.messaging.rsocket.RSocketStrategies;
import reactor.core.publisher.Mono;

import java.net.URI;

@Configuration
public class RSocketConfiguration {
    @LocalServerPort
    private int port;

    @Bean
    public Mono<RSocketRequester> rSocketRequester(RSocketStrategies rSocketStrategies, RSocketProperties rSocketProps){
        RSocketRequester rSocketRequester = RSocketRequester.builder()
                .rsocketStrategies(rSocketStrategies)
                .websocket(getURI(rSocketProps));
        return Mono.just(rSocketRequester);
    }

    private URI getURI(RSocketProperties rSocketProps) {
        return URI.create(String.format("ws://localhost:%d%s",
                port, rSocketProps.getServer().getMappingPath()));
    }

}

My Question
How do I prevent other origins to access my resources?
It might be worth mentioning that I am using spring-boot-starter-webflux instead of spring-boot-starter-web.



Solution 1:[1]

It's about the @CrossOrigin annotation, see Enabling Cross Origin Requests for a RESTful Web Service

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rupweb