GithubHelp home page GithubHelp logo

Comments (5)

erikerikson avatar erikerikson commented on August 25, 2024

In case someone finds this issue too...
@breandr It is. Just create a s-templates.json file at the root of your project and give it something like:

{
  "corsTemplate": {
    "allowOrigin": "*",
    "allowHeaders": ["Content-Type", "X-Amz-Date", "Authorization", "X-Api-Key"]
  }
}

Then in your s-function.json:

{
  ...
  "custom": {
    "cors": "$${corsTemplate}"
  }
  ...
}

from serverless-cors-plugin.

erikerikson avatar erikerikson commented on August 25, 2024

If you want to override it in a single or subset of functions, you can either create a s-templates.json as a peer to your s-function.json that redefines corsTemplate or you can just not use the template at all.

from serverless-cors-plugin.

brettstack avatar brettstack commented on August 25, 2024

Thanks, that's good to know. But what I was really hoping for was a "define once" solution. The template helps with reducing duplication, but ideally there would be no duplication and the functions would just inherit from the custom property in s-project.json. I'm new to serverless and not familiar with the patterns, so maybe this is a request for serverless core.

from serverless-cors-plugin.

joostfarla avatar joostfarla commented on August 25, 2024

@breandr previously (SLS < 0.5), you could also set the policy on the component level. Since the component concept has been dropped, it was required to set the policy on each function (with or without using templates).

I've just added support for setting the configuration on the project level. It's available in v0.4.1!

from serverless-cors-plugin.

brettstack avatar brettstack commented on August 25, 2024

So good! Thanks mate.

On Sun, 27 Mar 2016, 4:05 a.m. Joost Farla, [email protected]
wrote:

@breandr https://github.com/breandr previously (SLS < 0.5), you could
also set the policy on the component level. Since the component concept has
been dropped, it was required to set the policy on each function (with or
without using templates).

I've just added support for setting the configuration on the project
level. It's available in v0.4.1!


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#21 (comment)

from serverless-cors-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.