Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. #290

Closed
qihuang0 opened this issue Apr 20, 2023 · 10 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@qihuang0
Copy link

qihuang0 commented Apr 20, 2023

hi,
After I merged mr #236 to support namespaces, the web happened below failure:
172.18.123.48/:1
Access to XMLHttpRequest at 'http://172.18.123.48:32223/api/v1/namespaces//pods' from origin 'http://172.18.123.48:32222' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

image

But I have add --cors-allowed-origins in apiserver pod, I am not sure why this request was been blocked by cors

@qihuang0
Copy link
Author

/kind support

@k8s-ci-robot k8s-ci-robot added the kind/support Categorizes issue or PR as a support question. label Apr 23, 2023
@qihuang0
Copy link
Author

I am sorry to disturb you since I want to resolve this problem as soon as ~ @sanposhiho

@qihuang0
Copy link
Author

qihuang0 commented Apr 23, 2023

before merge (#236) , does not happened this issue

@sanposhiho
Copy link
Member

I cannot reproduce this.
Could you provide more info for me?:

  • do you start the simulator via docker or make start?
  • any reproduction process? (push any button, just start web UI with the simulator, etc

@qihuang0
Copy link
Author

qihuang0 commented Apr 23, 2023

I have developed a secondary version of a simulator and web application and integrated a scheduling visualization into the k8s scheduler, using the web front-end for display. It was working fine when there was only one namespace, and I added "--cors-allowed-origins" in the apiserver pod.
image
However, after updating to multiple namespaces, it seems to be ineffective.
image
Not in simulator, but directly connect to apiserver in real k8s cluster
By the way, I use a sidercar container to do "kubectl proxy" in webui pod to forward.

@sanposhiho
Copy link
Member

Not in simulator, but directly connect to apiserver in real k8s cluster

Ah, got it.
What I can tell here is the simulator configures the api-server with CorsAllowedOriginList option like you did via --cors-allowed-origins and it works well. (I confirmed that we can correctly create namespaces via web UI with api-server in the simulator.)

serverOpts.GenericServerRunOptions.CorsAllowedOriginList = corsAllowedOriginList

@qihuang0
Copy link
Author

qihuang0 commented Apr 25, 2023

😀I know, but I got this issue after pull that mr, and it worked well before merge it. I try fix this but not work, have to asked you for help hhh. Do you have any advice on this problem, since I am not know about typescript and not sure if this new mr could be used in APISERVER DIRECTLY CONNECT scene~

@Lan-ce-lot
Copy link
Contributor

😀I know, but I got this issue after pull that mr, and it worked well before merge it. I try fix this but not work, have to asked you for help hhh. Do you have any advice on this problem, since I am not know about typescript and not sure if this new mr could be used in APISERVER DIRECTLY CONNECT scene~

It seems that we have the same problem. My solution is to change the api/v1/namespaces // pods to api/v1/pods.
#312

@Lan-ce-lot
Copy link
Contributor

BTW, can I ask your version of your Apiserver? @qihuang0

@sanposhiho
Copy link
Member

We guess #313 should fix this. But feel free to reopen if the problem still exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

4 participants