Skip to content

CORS Issue while hitting Slack API from Front end App (React) #1568

Description

@Vignesh-raggy
  1. Whether Slack API Methods can be called from Front end Applications like react ?

  2. If yes then, We are calling the Slack API from front end web application which is created with react(i.e.. JavaScript framework) and this application is hosted in server now (i.e.. https web app).

We are getting CORS issue while calling any Slack API.

providing Detailed CORS Errors below:

Access to fetch at 'https://slack.com/api/auth.test' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field traceparent is not allowed by Access-Control-Allow-Headers in preflight response.

Access to fetch at 'https://slack.com/api/conversations.list' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field traceparent is not allowed by Access-Control-Allow-Headers in preflight response.
The same issue we got in Development environment (https hosted web app).

method 1: We are directly hitting this api https://slack.com/api/conversations.list with needed params.
method 2: And we are trying to use this library also to make api call - https://www.npmjs.com/package/@slack/web-api

in both the methods getting same CORS error.

Kindly Help us on this.

Our requirement : To Share a link from our front end application to any slack channels or DMs.
We planned to use conversations.list api to get all channels and DM list and post the message to particular channel using chat.postmessage API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions