2 years ago

#27627

test-img

nyavuzcan

Request blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space local

I have two projects on ubuntu server. I have a React and Spring Boot project running as a container. I expose frontend like 3000:3000 but I don't want to expose my backend project. I just want it to access from the react container.

I run my images like Spring Boot:

docker run -d registry.gitlab.com/my-backend-project

React:

docker run -d -p 3000:3000 registry.gitlab.com/my-frontend-project

this is exactly what i want. I can't access backend from remote host like http://remote-ip:8080 but i can access react project http://remote-ip:3000 also my react container can access spring boot container.

here is where my problem starts.

I test for ping and curl react container to spring boot container and I get success message.

export const example= (body) => {
return axios.post("http://localhost:8080/v1",body)

This is my react code. But like this in Chrome and many browser i get cors error lik:

Access to XMLHttpRequest at 'http://localhost:8080/v1/example' from origin 'http://remote-ip:3000' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space local.

I don't get this error in firefox and turning off "chrome://flags/#block-insecure-private-network-requests" setting in chrome successfully returns result. How can i fix this, Does what I do make sense?

spring-boot

docker

cors

containers

private-network-access

0 Answers

Your Answer

Accepted video resources