@remix-run/router 1.3.0-pre.2 → 1.3.0-pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # `@remix-run/router`
2
2
 
3
+ ## 1.3.0-pre.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix 404 bug with same-origin absolute redirects ([#9913](https://github.com/remix-run/react-router/pull/9913))
8
+ - Support `OPTIONS` requests in `staticHandler.queryRoute` ([#9914](https://github.com/remix-run/react-router/pull/9914))
9
+
3
10
  ## 1.3.0-pre.2
4
11
 
5
12
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.3.0-pre.2
2
+ * @remix-run/router v1.3.0-pre.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2556,7 +2556,7 @@ function createRouter(init) {
2556
2556
  } : {}));
2557
2557
  invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an external redirect that goes to a new origin
2558
2558
 
2559
- if (typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
2559
+ if (isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
2560
2560
  let newOrigin = init.history.createURL(redirect.location).origin;
2561
2561
 
2562
2562
  if (window.location.origin !== newOrigin) {
@@ -3036,7 +3036,7 @@ function createStaticHandler(routes, opts) {
3036
3036
  let location = createLocation("", createPath(url), null, "default");
3037
3037
  let matches = matchRoutes(dataRoutes, location, basename); // SSR supports HEAD requests while SPA doesn't
3038
3038
 
3039
- if (!isValidMethod(method) && method !== "head") {
3039
+ if (!isValidMethod(method) && method !== "head" && method !== "options") {
3040
3040
  throw getInternalRouterError(405, {
3041
3041
  method
3042
3042
  });
@@ -3552,6 +3552,16 @@ async function callLoaderOrAction(type, request, match, matches, basename, isSta
3552
3552
  }
3553
3553
 
3554
3554
  location = createPath(resolvedLocation);
3555
+ } else if (!isStaticRequest) {
3556
+ // Strip off the protocol+origin for same-origin absolute redirects.
3557
+ // If this is a static reques, we can let it go back to the browser
3558
+ // as-is
3559
+ let currentUrl = new URL(request.url);
3560
+ let url = location.startsWith("//") ? new URL(currentUrl.protocol + location) : new URL(location);
3561
+
3562
+ if (url.origin === currentUrl.origin) {
3563
+ location = url.pathname + url.search + url.hash;
3564
+ }
3555
3565
  } // Don't process redirects in the router during static requests requests.
3556
3566
  // Instead, throw the Response and let the server handle it with an HTTP
3557
3567
  // redirect. We also update the Location header in place in this flow so