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

Cross-Origin Request Blocked #51

Open
inyee786 opened this issue Feb 1, 2018 · 11 comments
Open

Cross-Origin Request Blocked #51

inyee786 opened this issue Feb 1, 2018 · 11 comments

Comments

@inyee786
Copy link

inyee786 commented Feb 1, 2018

 headers.append('Authorization', btoa('[email protected],key'));
      headers.append('Access-Control-Allow-Origin', 'https://{{domain}}.agilecrm.com');
      headers.append('Access-Control-Allow-Methods', 'POST');
      headers.append('Access-Control-Max-Age', '86400');

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://aliworkspace.agilecrm.com/dev/api/contacts. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

@sahil912
Copy link

I am facing the same issue, is there a solution to this one?

@sahil912
Copy link

 headers.append('Authorization', btoa('[email protected],key'));
      headers.append('Access-Control-Allow-Origin', 'https://{{domain}}.agilecrm.com');
      headers.append('Access-Control-Allow-Methods', 'POST');
      headers.append('Access-Control-Max-Age', '86400');

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://aliworkspace.agilecrm.com/dev/api/contacts. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Facing the same issue

@inyee786
Copy link
Author

I didn't use the rest-api library,
agile have nodejs library you can use that https://github.com/agilecrm/nodejs

@sahil912
Copy link

I want to implement this on front end react app. Is there a way to do it on react app?

@agilecrm
Copy link
Owner

agilecrm commented Oct 21, 2019 via email

@sahil912
Copy link

Please use Agile CRM JS api which takes care of CORS issue.

On Mon, Oct 21, 2019 at 10:54 AM sahil912 @.***> wrote: I want to implement this on front end react app. Is there a way to do it on react app? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#51?email_source=notifications&email_token=AARBBLIL3ZRCF4AJQNGOQDLQPU4H3A5CNFSM4EOZAD2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBZC3GA#issuecomment-544353688>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARBBLNWJK27U2SNCBLJPCDQPU4H3ANCNFSM4EOZAD2A .

Tried to use the JS API to create contact
contact is the json object

 axios.post("https://{domain}.agilecrm.com/dev/api/contacts", contact, {
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',

    },
    auth: {
        username: 'email',
        password: 'api_key'
    }
}).then(response => {
}).catch(error => {
});

Getting the following 401 error, attaching the screenshot:

image

@seleckis
Copy link

seleckis commented Nov 8, 2019

@sahil912 you need to add your host to allowed domains in agilecrm admin settings

@andyfaizan
Copy link

andyfaizan commented Mar 26, 2020

I'm facing the same issue while using the NodeJS library. @seleckis Where exactly can one do that? Can you share a screenshot. Did you mean Admin Settings -> Preferences -> Security (to add IPs).
FYI: I have a free account if that matters

@seleckis
Copy link

@andyfaizan Admin Settings -> Analytics -> Allowed Domains

@andyfaizan
Copy link

Still doesn't work unfortunately. I can cURL the API and it works since the cURL sends a direct POST request whereas the browser sends an OPTIONS request first and it goes through the auth and gets a 401. OPTIONS should always be allowed on the server side.

@goerkemballmueller
Copy link

any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants