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

Visiting index with Root Slash and Base normalizes URL in dev #1258

Closed
AleksandarFaraj opened this issue Nov 14, 2023 · 10 comments
Closed

Visiting index with Root Slash and Base normalizes URL in dev #1258

AleksandarFaraj opened this issue Nov 14, 2023 · 10 comments
Labels

Comments

@AleksandarFaraj
Copy link

AleksandarFaraj commented Nov 14, 2023

Description

I am trying to create an index page with a vite base path.

// vite.config.ts
export default {
  base: "/local/"
}

Expected:

  1. vite dev
  2. http:https://localhost:3000/local/
  3. Shows index page.

Actual:

  1. vite dev
  2. http:https://localhost:3000/local/
  3. URL redirect: http:https://localhost:3000/local
  4. Vite: 'did you mean /local/?'
@brillout
Copy link
Member

AFAICT this is fine, but feel free to elaborate if you believe otherwise and I'll then re-open.

@brillout brillout closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2023
@AleksandarFaraj
Copy link
Author

Well this is a huge pain because there is no way to actually open the index page when base is specified.

In essence; without this fix, vike does not support vite base.

@brillout
Copy link
Member

You can set the base to /local instead, or wouldn't that work for you?

@AleksandarFaraj
Copy link
Author

We have multiple product surfaces and we do not have it as a single spa. Using base /local breaks relative redirects.

Vite reference:
https://vitejs.dev/config/shared-options.html#base

@brillout
Copy link
Member

I'm not sure I understand your point.

@AleksandarFaraj
Copy link
Author

AleksandarFaraj commented Nov 14, 2023

Sorry about that.

The base property for vite expects it to have a trailing slash. Specifically for our case we utilise relative links (not vike router or react router spa) when sending users from landing page (/) to auth (/auth) and app (/app). Those would break with base=/local because relative redirect to (app) from /local is /app not /local/app

https://vitejs.dev/config/shared-options.html#base
base
Type: string
Default: /
Base public path when served in development or production. Valid values include:

Absolute URL pathname, e.g. /foo/

@brillout
Copy link
Member

The base property for vite expects it to have a trailing slash

That isn't true.

our case we utilise relative links (not vike router or react router spa) when sending users from landing page (/) to auth (/auth) and app (/app)

Is there a reason you don't use absolute links? In general, relative links are inherently broken in apps that have mutliple pages.

To be clear: I'm not saying Vike shouldn't support Base URLs with a trailing slash, but it doesn't seem high priority either.

@brillout
Copy link
Member

Thanks for the feedback; you were right with the relative paths being bad and I improved our code to not depend on relative URLs.

👍

But I ran into another parity issue, storybook utilises base ./ which vike doesn't support

Relative Base URLs also don't make much sense for multi-page apps, see #606.

@brillout
Copy link
Member

@brillout
Copy link
Member

support Base URLs with a trailing slash

Fixed and pre-released as 0.4.146-commit-701e2e5.


@AleksandarFaraj Btw. would your company be up for sponsoring?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants