netlify-local icon indicating copy to clipboard operation
netlify-local copied to clipboard

Correctly implement Redirect feature

Open 8eecf0d2 opened this issue 5 years ago • 0 comments

This is a pretty insane feature considering what it's called, what it's actually capable of, and how it's implemented...

Notice: It's confusing and important to understand if the "redirect rule" in question is a true 3xx style redirect or a more fancy rewrite.

The main features to implement:

  • [x] Traditional Redirect
  • [x] Traditional Rewrite (to filesystem / build.publish)
  • [x] Proxy Rewrite
  • [x] Placeholder / Pattern matching

Redirect Features

Basic Redirects / Rewrites, Http Status Codes

Netlify will return status code 301 for what it calls basic redirects. Netlify will perform a rewrite if a status code is set and not equal to 301, 302, 303.

  • [x] Support "basic redirect"
  • [x] Support "basic rewrite"

Custom 404

By default Netlify will serve a 404.html file if it's provided and no redirect rules or static files match the path.

  • [ ] Support for custom 404.html

Trailing Slashes

I'm not even gonna bother with this yet...

Placeholders

Basically param swapping between from and to - should be easy enough to implement with express and a url pattern library.

from = "/:partA/:partB"
to = "/:partB/:partA"
# "/foo/bar" → "/bar/foo"
  • [x] Support placeholder / pattern replacement

Splats 🤦‍♀️

Similar to placeholders except the * and :splat param are bound.

  • [x] Support special splat placeholder

Query Params

More or less states that query params can be used as placeholders, the syntax is weird but toml is luckily more readable that Netlify's _redirect file formatting.

  • [ ] Support query placeholder

Hostnames & Protocols, GeoIP & Language

These feature are getting way beyond my personal use cases - plus I don't see them being entirely useful for local development, it'd be great to support them but I'm not holding my breath.

8eecf0d2 avatar Oct 17 '18 09:10 8eecf0d2