-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
AWS API Gateway: Improve validation of CORS configuration #9858
Comments
@justingrant by schema either
|
@pgrzesik I think that we probably can improve an UX of that. Remove that |
Hey @justingrant as @medikoo mentioned, either |
As I checked, currently when none are provided, generated CORS configuration ends with I've updated the issue title. PR that improves that validation is welcome! It's purely about:
|
Oh! Thanks so much for the info and the pointer to the relevant sources. Given that the TS type in I filed serverless/typescript#49 for the bad TS types. @medikoo @pgrzesik - is there an example of the type of exception and error message that is used elsewhere for config validation? Anyone fixing this will want to follow precedent. |
Hello @justingrant 👋 Are you asking about error that is thrown as a part of our schema validation based on schema definition or about errors for specific scenarios? We have general schema validation, but some rules are really hard to properly express in JSON Schema so sometimes we resort to custom validation where errors have specific codes. In all cases, the error will be of serverless/lib/serverless-error.js Line 3 in 7e9bfd6
INVALID_NON_SCHEMA_COMPLIANT_CONFIGURATION .
|
As @pgrzesik explained. Still I'd keep Here we're going to introduce validation error but via different means and in such case we introduce more specific error code. serverless/lib/plugins/aws/package/compile/events/cloudFront.js Lines 264 to 276 in 7e9bfd6
|
Hello @issea1015 👋 That would be very welcome, thank you 🙇 |
@issea1015 that'll be great, we look forward the PR! |
I found some other perspectives in the code:
We still can make it strict to require explicit @medikoo @pgrzesik Could you let me know what do you think? Thanks in advance 🙇 |
@issea1015 indeed, very good find. I believe approach is to assume same default for In light of that I think we should simply remove conditional requirement for @pgrzesik what do you think? |
That's a good find @issea1015 - I think we should remove the requirement on |
Serverless CLI commands report a configuration warning about CORS configuration for AWS Lambda functions when using the expanded (non-boolean) format of CORS config. I copied this configuration from Serverless's own blog post about configuring CORS support for Lambda functions. I'm using the second configuration format in the post that allows
origin
,headers
, andallowCredentials
properties under thecors
key. (The other way to configure CORS is simply to use a boolean value.)This configuration format also matches the TS types for the cors key in @types/serverless: https://github.com/serverless/typescript/blob/b700b729a0ad15aac0a6ed9dc146047a2a7aa583/index.d.ts#L190-L199
I get this error:
serverless.yml
SLS_DEBUG=* sls info
outputInstalled version
The text was updated successfully, but these errors were encountered: