reactjs 解释MapIP地址

yxyvkwin  于 2023-03-08  发布在  React
关注(0)|答案(1)|浏览(128)

我有一个项目,我想在本地服务器上托管,我遇到了奇怪的事情。我有我的后端部分运行在8080端口和前端3000端口,我玩了一下分别托管后端和前端。这里是我不明白的事情:当我这样主持的时候

back-end :  localhost:8080
        front-end : 192.168.50.41:3000

back-end : 192.168.50.41:8080
        front-end : localhost:3000

它工作得非常好(我的意思是所有来自前端的请求都能成功到达后端)
但是如果主人是这样

back-end : 192.168.50.41:8080
        front-end : 192.168.50.41:3000

它抛出CORS错误,但是我在application.yml文件中更改了CORS配置,如下所示

cors:
          allowed-origins: http://192.168.50.41:3000

          allowed-endpoints: > 
           /api/v1/auth/login,
           /api/v1/auth/register,

这是我的安全配置

@Bean
              public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {

    http
            .cors()
            .and()
            .csrf()
            .disable()
            .exceptionHandling()
            .authenticationEntryPoint(authEntryPoint)
            .and()
            .sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .authorizeHttpRequests()
            .requestMatchers("/api/v1/auth/login")
            .permitAll()
            .anyRequest()
            .authenticated()
            .and()
            .authenticationProvider(authenticationProvider)
            .addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
    ;`

也许有人遇到过这样的问题,知道解决办法,因为我想我在配置中错过了smth

sauutmhj

sauutmhj1#

它基本上是端口,8080是为主要的网络服务器。次要的网络服务器不使用它。
Trend Micro Antivirus products may use port 3000 UDP to communicate with their servers.,因此您不能使用已为其他端口定义端口
端口3000可能是主/默认HTTP的端口,您可以使用http。

相关问题