Topic: Issue With Cors in API Module

https://github.com/cambell-prince/Front … gSimpleAPI

This is API module above that we are using to integrate with with our external React App.

The issue regarding this module is that whenever we try to make an API request to any endpoint provided in this module

i.e: www.baseurl.com/modules/api/category

it always gives an error regarding Allowed Origin not present in headers (CORS) but on the other hand when we are trying the same exact endpoint with Postman it runs as it is supposed to run.

I have gone through the help at slim framework site and found the solution below. But I am not sure where to embed this code in our API module.

https://www.slimframework.com/docs/v3/c … -cors.html


Kindly help us resolve this issue

Thanks for helping and coorperating.

Re: Issue With Cors in API Module

You are trying in the browser. Try post man or similar to this .


And also slim 3 has been used on this api.  Currently we are trying with slim 4 and access token based authentication.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Issue With Cors in API Module

I think it is built on react technology so the guy needs to access the API through browser. The CORS error is specific with browser and not with POSTMAN.

Your second point I couln't get. The above mentioned gihub link for module for API is on SLIM3 or SLIM4 I couldn't ge this?

www.boxygen.pk

Re: Issue With Cors in API Module

To be with react, i am not sure. But with node you can try express and cors together.

const express = require('express');
const cors = require('cors');

const app = express();

// Allow requests from all origins (for development purposes)
app.use(cors());

I meant I am trying to make a rest api with slim 4 and instead of username and password for every call. Trying to do with access token based authentication.

First time they need to login with email and password and response will provide  a token. And based on that token further api calls so operate.

Subscription service based on FA
HRM CRM POS batch Themes