API Gateway POST request returns "error http://localhost:3000 is not allowed by...











up vote
0
down vote

favorite












So I'm trying to write a POST method that triggers a lambda function which will in turn write to a DynamoDB database. The logic behind all of that seems fine, and I can invoke the lambda function when I make a POST request to the API through POSTMAN. However, when I try to do the same from my actual application, which doesn't currently have a domain, I get the error:




Type error: Origin http://localhost:3000 is not allowed by
Access-Control-Allow-Origin




Since I don't have a domain I am developing using localhost:3000. Can I get this to work with API Gateway? I already have CORS setup with [*] as my list of domains, so this should be open to every domain.










share|improve this question
























  • Have you enabled CORS on your API Gateway Resource? There's a checkbox you can use to enable it easily.
    – AlexK
    Nov 19 at 8:54










  • Yes CORS is enabled. I'm wondering if it's an issue with using localhost:3000 as my origin. Like I said it works through Postman
    – KSamra
    Nov 19 at 22:38















up vote
0
down vote

favorite












So I'm trying to write a POST method that triggers a lambda function which will in turn write to a DynamoDB database. The logic behind all of that seems fine, and I can invoke the lambda function when I make a POST request to the API through POSTMAN. However, when I try to do the same from my actual application, which doesn't currently have a domain, I get the error:




Type error: Origin http://localhost:3000 is not allowed by
Access-Control-Allow-Origin




Since I don't have a domain I am developing using localhost:3000. Can I get this to work with API Gateway? I already have CORS setup with [*] as my list of domains, so this should be open to every domain.










share|improve this question
























  • Have you enabled CORS on your API Gateway Resource? There's a checkbox you can use to enable it easily.
    – AlexK
    Nov 19 at 8:54










  • Yes CORS is enabled. I'm wondering if it's an issue with using localhost:3000 as my origin. Like I said it works through Postman
    – KSamra
    Nov 19 at 22:38













up vote
0
down vote

favorite









up vote
0
down vote

favorite











So I'm trying to write a POST method that triggers a lambda function which will in turn write to a DynamoDB database. The logic behind all of that seems fine, and I can invoke the lambda function when I make a POST request to the API through POSTMAN. However, when I try to do the same from my actual application, which doesn't currently have a domain, I get the error:




Type error: Origin http://localhost:3000 is not allowed by
Access-Control-Allow-Origin




Since I don't have a domain I am developing using localhost:3000. Can I get this to work with API Gateway? I already have CORS setup with [*] as my list of domains, so this should be open to every domain.










share|improve this question















So I'm trying to write a POST method that triggers a lambda function which will in turn write to a DynamoDB database. The logic behind all of that seems fine, and I can invoke the lambda function when I make a POST request to the API through POSTMAN. However, when I try to do the same from my actual application, which doesn't currently have a domain, I get the error:




Type error: Origin http://localhost:3000 is not allowed by
Access-Control-Allow-Origin




Since I don't have a domain I am developing using localhost:3000. Can I get this to work with API Gateway? I already have CORS setup with [*] as my list of domains, so this should be open to every domain.







amazon-web-services aws-api-gateway






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 9:41









Ryan Lee

293




293










asked Nov 19 at 4:31









KSamra

405




405












  • Have you enabled CORS on your API Gateway Resource? There's a checkbox you can use to enable it easily.
    – AlexK
    Nov 19 at 8:54










  • Yes CORS is enabled. I'm wondering if it's an issue with using localhost:3000 as my origin. Like I said it works through Postman
    – KSamra
    Nov 19 at 22:38


















  • Have you enabled CORS on your API Gateway Resource? There's a checkbox you can use to enable it easily.
    – AlexK
    Nov 19 at 8:54










  • Yes CORS is enabled. I'm wondering if it's an issue with using localhost:3000 as my origin. Like I said it works through Postman
    – KSamra
    Nov 19 at 22:38
















Have you enabled CORS on your API Gateway Resource? There's a checkbox you can use to enable it easily.
– AlexK
Nov 19 at 8:54




Have you enabled CORS on your API Gateway Resource? There's a checkbox you can use to enable it easily.
– AlexK
Nov 19 at 8:54












Yes CORS is enabled. I'm wondering if it's an issue with using localhost:3000 as my origin. Like I said it works through Postman
– KSamra
Nov 19 at 22:38




Yes CORS is enabled. I'm wondering if it's an issue with using localhost:3000 as my origin. Like I said it works through Postman
– KSamra
Nov 19 at 22:38












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Try to



change localhost to "lvh.me" which points to 127.0.0.1



or



edit your hosts file so that local.[mysite].com points to 127.0.0.1, then make your CORS file allow *.[mysite].com



check:
stack






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368347%2fapi-gateway-post-request-returns-error-http-localhost3000-is-not-allowed-by%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Try to



    change localhost to "lvh.me" which points to 127.0.0.1



    or



    edit your hosts file so that local.[mysite].com points to 127.0.0.1, then make your CORS file allow *.[mysite].com



    check:
    stack






    share|improve this answer

























      up vote
      0
      down vote













      Try to



      change localhost to "lvh.me" which points to 127.0.0.1



      or



      edit your hosts file so that local.[mysite].com points to 127.0.0.1, then make your CORS file allow *.[mysite].com



      check:
      stack






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Try to



        change localhost to "lvh.me" which points to 127.0.0.1



        or



        edit your hosts file so that local.[mysite].com points to 127.0.0.1, then make your CORS file allow *.[mysite].com



        check:
        stack






        share|improve this answer












        Try to



        change localhost to "lvh.me" which points to 127.0.0.1



        or



        edit your hosts file so that local.[mysite].com points to 127.0.0.1, then make your CORS file allow *.[mysite].com



        check:
        stack







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 at 13:41









        guzial

        6312




        6312






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368347%2fapi-gateway-post-request-returns-error-http-localhost3000-is-not-allowed-by%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Ottavio Pratesi

            Tricia Helfer

            15 giugno