CORS ERROR when setup Omada controller wit external portal

CORS ERROR when setup Omada controller wit external portal

CORS ERROR when setup Omada controller wit external portal
CORS ERROR when setup Omada controller wit external portal
2 weeks ago - last edited 2 weeks ago

Hello Community,

I successfully integrated my access point with my remote controller, but I’m encountering an issue with the CORS policy.

My external portal is deployed on rayen.github.io, and my controller is hosted on omada-dev.xxxxx.io. When I send a POST request to authenticate the operator, I receive a CORS error.


Could you please guide me on how to resolve this issue?

Here’s the code for the request:


 

async function loginOperator(username, password) { const url = 'https://omada-dev.xxxxx.io:8043/fsdfdsfdsffdsfdsfdsfsdfds/api/v2/hotspot/login'; const options = { method: 'POST', headers: { 'content-type': 'application/json', 'Accept': 'application/json', 'Access-Control-Allow-Origin': 'https://rayen.github.io', }, body: '{"name":"name","password":"password"}' }; try { const response = await fetch(url, options); const data = await response.json(); alert(data); } catch (error) { alert(error); } }

 

  0      
  0      
#1
Options
1 Accepted Solution
Re:CORS ERROR when setup Omada controller wit external portal -Solution
2 weeks ago - last edited 2 weeks ago

Hi  @Rayen_CR 

 

It is incorrect to set the 'Access-Control-Allow-Origin' header in the client-side request. This header should be set by the server, not the client.

Wish you a happy life and smooth network usage! 
Recommended Solution
  0  
  0  
#2
Options
2 Reply
Re:CORS ERROR when setup Omada controller wit external portal -Solution
2 weeks ago - last edited 2 weeks ago

Hi  @Rayen_CR 

 

It is incorrect to set the 'Access-Control-Allow-Origin' header in the client-side request. This header should be set by the server, not the client.

Wish you a happy life and smooth network usage! 
Recommended Solution
  0  
  0  
#2
Options
Re:CORS ERROR when setup Omada controller wit external portal
2 weeks ago

  @Vincent-TP 

I use Nginx as the web server with blocks, and I have set the following CORS headers:

add_header Access-Control-Allow-Origin "https://rayen.github.io";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, DELETE, PUT";
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept, X-Requested-With";

However, the error still persists.  

  0  
  0  
#4
Options

Information

Helpful: 0

Views: 131

Replies: 2

Related Articles