Skip to content

404 error on SearchForm component #1351

@eupthere

Description

@eupthere

Most appropriate sections of the p5.js website?

Home

What is your operating system?

Mac OS

Web browser and version

Firefox 149.0.2

Actual Behavior

The search bar directs to a URL without the trailing slash, such as /search?term=..., which results in a 404 page in local development.

Image Image

Expected Behavior

The search bar should direct to the search page URL with the trailing slash, such as /search/?term=..., so the search results page loads correctly. The deployed site appears to work because the production server likely adds the missing trailing slash automatically, as noted in the project documentation:

### Automatic trailing slash addition
While the production webserver _may_ add a trailing slash to a requested URL when it is missing, but this should not be relied upon.
Instead write (or generate) links that follow the rules above.

Solution

Add a trailing slash here:

action={`${currentLocale === "en" ? "" : `/${currentLocale}`}/search`}

Note on Search Results page

The search bar on the Search Results page works because it does not navigate to a new page. It stays on /search/ and updates the query in place on the client side.

const submitInput = () => {
if (inputRef.current) {
onSearchChange(inputRef.current.value);
}
};

By contrast, SearchForm submits a normal GET request to /search without the trailing slash. In local development, that can resolve to a 404 instead of the search results page.

Steps to reproduce

main, 2.0 branch both affected.

npm run dev
npm run preview

Put search keyword on the search bar on home page.

Would you like to work on the issue?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions