Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Fetch CORS issue #34152

Open
1 task done
gootik opened this issue Jun 10, 2024 · 3 comments
Open
1 task done

[Bug]: Fetch CORS issue #34152

gootik opened this issue Jun 10, 2024 · 3 comments
Assignees
Labels
Bug Something isn't working Cannot Reproduce Issue Issues that cannot be reproduced Community Reported issues reported by community members FE Coders Pod Issues related to users writing javascript in appsmith Framework Functions Cases related to internal functions like showAlert(), navigateTo() etc... Needs Triaging Needs attention from maintainers to triage Production

Comments

@gootik
Copy link

gootik commented Jun 10, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description

When I use fetch() on the client side it cannot load resources because of CORS issue.

Steps To Reproduce

  1. Go to Edit mode of any application
  2. create a custom JS function
  3. add a fetch operation like await fetch('https://api.ipify.org?format=json')
  4. See that browser blocks call with "CORS Missing Allow Origin" error

Public Sample App

No response

Environment

Production

Severity

High (Blocker to building or releasing)

Issue video log

No response

Version

Self Hosted - v1.27

@gootik gootik added Bug Something isn't working Needs Triaging Needs attention from maintainers to triage labels Jun 10, 2024
@Nikhil-Nandagopal Nikhil-Nandagopal added Community Reported issues reported by community members High This issue blocks a user from building or impacts a lot of users Production Framework Functions Cases related to internal functions like showAlert(), navigateTo() etc... labels Jun 10, 2024
@github-actions github-actions bot added the FE Coders Pod Issues related to users writing javascript in appsmith label Jun 11, 2024
@Nikhil-Nandagopal
Copy link
Contributor

@gootik we'll look into this. In the meanwhile, you can hit that URL using the regular API query
Screenshot 2024-06-11 at 12 48 49 PM

@gootik
Copy link
Author

gootik commented Jun 11, 2024

Thank you @Nikhil-Nandagopal , for this specific issue we would want the call to be from the Client side not server side. so the regular API query would not be sufficient :( Unless we can force the API query to run from client rather than appsmith server?

@rishabhrathod01
Copy link
Contributor

@gootik Could you please share the exact error you notice in the browser by sharing a screenshot of the same?

Also, the implementation for extracting the JSON with a fetch for your case should be as shown below.

async myFun2 () {
	return await fetch('https://api.ipify.org?format=json').then(res => res.json())
}

@Nikhil-Nandagopal Nikhil-Nandagopal added Cannot Reproduce Issue Issues that cannot be reproduced and removed High This issue blocks a user from building or impacts a lot of users labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Cannot Reproduce Issue Issues that cannot be reproduced Community Reported issues reported by community members FE Coders Pod Issues related to users writing javascript in appsmith Framework Functions Cases related to internal functions like showAlert(), navigateTo() etc... Needs Triaging Needs attention from maintainers to triage Production
Projects
None yet
Development

No branches or pull requests

5 participants