SPA +WEB Integartion

SPA +WEB Integartion

Hi ,I have created React application (SPA in Okta) and Java Spring Boot application (WEB in Okta) in Okta its working fine in React ,when i hit UI url it is navigating okta sing in page and coming back to Home page and for Java API also its working fine ,when i hit API URL in browser its navigating to Okta sign in and coming back to api and its displaying response in browser.

Now the problem is when i call API in react application on button click am getting CORS issue browser not allowing to redirect to Okta from API (UI -API -Okta sign in ). How can I Integrate SPA and WEB .I tried Token validation but if i follow token validation its working through React App but if user hit API URL in browser its throwing unauthorized error because there is no token …

Please help me how to handle this scenario

Whats the CORS error you are seeing?

Hi andrea, am getting below CORS issue when I call Okta API from UI which is running port 300 and my Spring Boot API running 8082.

Here Spring boot API and React apps create in Okta

Access to XMLHttpRequest at ‘okta-dev-57912054 - Sign In’ (redirected from ‘http://localhost:8081/home’) from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Are you trying to make a CORS request to the authorize endpoint? This endpoint does not support AJAX requests and your application must redirect to this route to log users in, as doc’d here.

I have React application and Spring Boot application. I have created SPA for React application which is working fine when user open React App URL in browser its navigating to Okta and authenticating upto this is fine . Now for my back end spring boot app i have created WEB app in Okta .

Now I have SPA app in Okta for React and WEB app for Spring boot app(back end apis) with different clinet id’s and one secrete key for WEB app.

Now when When user open React UI its asking authenticating from Okta once user enter credentials its redirecting to React Home page ,In Home page am calling Spring boot API call here am getting CORS issue I tried to disable CORS in browser after that am getting Login HTML code from Spring boot API .

I want to know how can i call API which is integrated in Okta from UI