• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CORS Issue with Coldfusion REST API local

Community Beginner ,
Jun 19, 2022 Jun 19, 2022

Copy link to clipboard

Copied

Hey there,

 

I'm playing around with CF locally with a Reac Front End, for speed of testing I'm using the built in webserver to see whether it's work keeping legacy CF components for a REST API.

 

I can get the GET and POST methods to work but am getting a CORS issue with DELETE.

 

I've tried including the following inside my Rest service but still no luck.

 

<cfheader name="Access-Control-Allow-Origin" value="*" />
<cfheader name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE" />
<cfheader name="Access-Control-Allow-Headers" value="Content-Type" />
 
Any help would be much appreciated.
Cheers

Views

572

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jun 20, 2022 Jun 20, 2022

Thanks guys for the reply.

 

I managed to get it working by setting up Apache, and running the connector, creating and signing my own cert for MacOS and then adding in the correct headers inside my virtual directory.

 

Bit of a stuff around by everything works as it should

 

Cheers

Votes

Translate

Translate
Community Expert ,
Jun 20, 2022 Jun 20, 2022

Copy link to clipboard

Copied

Could you please tell us what the issue is?

 

What do you do? What do you get as a result? Please share the relevant code and error messages.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 20, 2022 Jun 20, 2022

Copy link to clipboard

Copied

In any case, you can simply use the OPTIONS request to ask the API whether it allows DELETE. Something like:

 

<cfhttp url="https://reqres.in/api/users" method="options">
	<cfhttpparam type="header" name="Access-Control-Request-Methods" value="DELETE" >
</cfhttp>
<cfdump var="#cfhttp#" >

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 20, 2022 Jun 20, 2022

Copy link to clipboard

Copied

Thanks guys for the reply.

 

I managed to get it working by setting up Apache, and running the connector, creating and signing my own cert for MacOS and then adding in the correct headers inside my virtual directory.

 

Bit of a stuff around by everything works as it should

 

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2022 Jun 21, 2022

Copy link to clipboard

Copied

LATEST

Thanks for sharing that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation