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

Added the ability to use CORS for all sources #27

Closed
wants to merge 0 commits into from

Conversation

ilyajob05
Copy link
Contributor

Enabled the ability to use CORS for all sources
Cross-Origin Resource Sharing (CORS)

@ilyajob05
Copy link
Contributor Author

Hi all!
I added the ability to include braids in the header; to do this, just add a flag -lets-CORS to the arguments and checked the functionality

./s3www -endpoint "https://s3-aws.com" -accessKey "KEY" -secretKey "KEY" -bucket "bucket" -address "0.0.0.0:80" -lets-CORS

Copy link
Owner

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to enable cors add rs/cors dependency and use that handler instead.

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
Copy link
Owner

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also add, allowedorigins can be skipped for now, because we can take those as options

--allowed-cors-origins "http://example.com,http://example2.com"
        opts := cors.Options{
                AllowOriginFunc: func(origin string) bool {
                        if allowedCorsOrigin == "" {
                                return true
                        }
                        for _, allowedOrigin := range strings.Split(allowedCorsOrigin, ",") {
                                if wildcard.MatchSimple(allowedOrigin, origin) {
                                        return true
                                }
                        }
                        return false
                },
                AllowedMethods: []string{
                        http.MethodGet,
                        http.MethodPut,
                        http.MethodHead,
                        http.MethodPost,
                        http.MethodDelete,
                        http.MethodOptions,
                        http.MethodPatch,
                },
                AllowedHeaders:   []string{"*"},
                ExposedHeaders:   []string{"*"},
                AllowCredentials: true,
        }
        return cors.New(opts).Handler(handler)

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@ilyajob05
Copy link
Contributor Author

@harshavardhana hi!
the workflow is still awaiting approval from the maintainer

Copy link
Owner

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me think about this.

go.mod Outdated
@@ -5,6 +5,8 @@ go 1.18
require (
github.com/caddyserver/certmagic v0.17.2
github.com/minio/minio-go/v7 v7.0.61
github.com/minio/pkg v1.7.5
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there is a problem we can't link this package here since minio/pkg is AGPLv3

@harshavardhana
Copy link
Owner

This is merged here b906d89

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

Successfully merging this pull request may close these issues.

None yet

2 participants