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

fix the wrong path configuration in root redirection #6215

Merged
merged 1 commit into from
Apr 16, 2019

Conversation

MasashiSalvador57f
Copy link
Contributor

What is included

  • tiny bug fix for the configuration of root redirection

As before

when you setup root redirection for the gateway or endpoint, you can configure RootRedirect in your configuration file as

  "Gateway": {
   .... // omitted ...
    "NoFetch": false,
    "PathPrefixes": [],
    "RootRedirect": "PATH_TO_REDIRECTION",
    "Writable": false
  },

currently the configuration doesn't seem to work well, because

	if len(cfg.Gateway.RootRedirect) > 0 {
		opts = append(opts, corehttp.RedirectOption("", cfg.Gateway.RootRedirect))
	}

and when path = "" Handler for redirection will be set to "//"

	return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
		mux.Handle("/"+path+"/", handler)
		return mux, nil
	}

in local

curl localhost:5001 # returns 404

fix

as I fixed in the diff, handle correctly the case for root redirection.

@MasashiSalvador57f
Copy link
Contributor Author

wow, I need to fix it for GitCop... :)

 before: when path = "" => // -> handler
 after: when path = "" => / -> handler

License: MIT
Signed-off-by: Masashi Salvador Mitsuzawa <masashisalvador57f@gmail.com>
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

I'll merge this after the release. Thanks!

@Stebalien Stebalien merged commit ee12dde into ipfs:master Apr 16, 2019
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.

2 participants