Skip to content

Weird redirection when using Router and Route #457

@ntdung34

Description

@ntdung34

Describe the bug

Please see the code below:

import { lazy, onMount } from "solid-js";
import { Router, Route } from "@solidjs/router";

const
    NotFoundPage = lazy( () =( import( "./app/not-found.tsx" ) ) ),
    UnauthenticatedLayout = lazy( () =( import( "./app/(unauthenticated)/layout.tsx" ) ) ),
    SignInPage = lazy( () =( import( "./app/(unauthenticated)/sign-in/page.tsx" ) ) ),
    AuthenticatedLayout = lazy( () =( import( "./app/(authenticated)/layout.tsx" ) ) ),
    DashboardPage = lazy( () =( import( "./app/(authenticated)/dash/page.tsx" ) ) );

const App = () ={

    return (

        <Router>

            <Route component={ UnauthenticatedLayout }>
                <Route path="/" component={ SignInPage } />
            </Route>

            <Route component={ AuthenticatedLayout }>
                <Route path="/dash" component={ DashboardPage } />
            </Route>

            <Route path="*404" component={ NotFoundPage } />

        </Router>

    );

}

export default App;

In this app, the following routes are included:

  • http://localhost:5173 - Sign in page
  • http://localhost:5173/dash - Dashboard page

If I access http://localhost:5173, or http://localhost:5173/dash; well, everything works normally. But, if I go to http://localhost:5173//dash, it always shows the Sign in page (without redirecting to http://localhost:5173), instead of the Not Found page.

Is this because I have configured the Router and Route components incorrectly, or is this a bug? Please let me know!

Thank you in advance.

Your Example Website or App

.

Steps to Reproduce the Bug or Issue

  1. Access the browser with the link http://localhost:5173//dash
  2. See error

Expected behavior

Temporarily, what is the way to solve this problem?

Screenshots or Videos

No response

Platform

  • OS: Windows 10
  • Browser: Firefox
  • Version: 127.0.1 (64-bit)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions