
12 answers
Unfortunately you won't really be able to do so without a publicly available IP address and server. Generally you can mock REST services to simulate the responses as given to you from Salesforce but that's limited and slightly time consuming to set up. I would suggest that if you guys were in it for the long haul and intend to develop as agile as possible then you can throw your content up on any server quickly. This will save you months of pain if you can retrieve content from and fully validate your requests. Amazon AWS can can set up in a relatively short time that you can host your code from (free for a year?). If the content is short and sweet and you only have one call to ever make (say for a small retrievable of newest Opp for example) then I would suggest you can eyeball it... but again best practices will get you further than malpractices.The only other way is to possibly have a service that retrieves that data for you (may already be built) and then you retrieve that from there. Again, this violates a lot of the principles behind CORS and you really should just get a server :) It sounds like you're trying to add "localhost" as a supported IP address to your Salesforce CORS list. Though my experience doesn't extend to salesforce completely, if I'm accurate it means you're telling Salesforce to:Accept all incoming requests from the origin: https://localhost:8080This translates toAccept all incoming requests from yourself coming from the port 8080What you really want is for your website that accesses this REST api to retrieve it via a publicly available server ip or dns that can access. Remember, you're telling Salesforce what IPs are applicable, if you say localhost or 127.0.0.1 then you're saying accept all requests from the Salesforce home server. If don't have a publicly available server you may need to look into that seperately.Hope that helps! Your welcome Eric. Please mark the question as resolved. Thanks for the responses. I think we will solve it with a middle tier service to connect with SF rest api. Hi Eric,read this article below. Maybe suggestions there would help oyuhttps://developer.salesforce.com/blogs/developer-relations/2015/01/spring-15-preview-cors-force-com-rest-api.html.try hosting oyur app on heorku to test it Hi Peter,Eventually this will be hosted on a web server, but for development we need to be able to work on it locally. Do you have any suggestion for a better approach we can do? Thanks! I tried http in the beginning, but I must enter a https url when setup CORS and add it to whitelist. So, I did it with https. I setup the https protocol on my localhost. What else should I check? Thanks. Did u try making a connection using https, not http. I know salesforce doesnt like insecure connections
Other work around would be to make your rest spi publicly accessible using
force.comsite. But not sure if u wonna go that route
_____________________________
I need it as a stand alone application for the business requirement. Is there any work around for this? Or I must do it with apex? Thanks. I would recommend doing REST calls from apex rather then client side. You won't have this issue if oyu move your call to your controlelr and call the apex method instead form angular