Skip to content

fix: serve and preview with base#8772

Closed
JounQin wants to merge 5 commits intovitejs:mainfrom
JounQin:fix/base
Closed

fix: serve and preview with base#8772
JounQin wants to merge 5 commits intovitejs:mainfrom
JounQin:fix/base

Conversation

@JounQin
Copy link
Contributor

@JounQin JounQin commented Jun 24, 2022

Description

close #8770

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@netlify
Copy link

netlify bot commented Jun 24, 2022

Deploy Preview for vite-docs-main ready!

Name Link
🔨 Latest commit 5c2805a
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62c1ccd301c1740008e9ca51
😎 Deploy Preview https://deploy-preview-8772--vite-docs-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

) {
// redirect root visit to based url with search and hash
res.writeHead(302, {
Location: devBase + (parsed.search || '') + (parsed.hash || '')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed.search and parsed.hash will never be null/undefined.

@sapphi-red sapphi-red added the p2-nice-to-have Not breaking anything but nice to have (priority) label Jul 3, 2022
@JounQin JounQin changed the title fix: serve with base fix: serve and preview with base Jul 3, 2022
@benmccann
Copy link
Collaborator

This won't really work with SvelteKit. We have a trailingSlash option which indicates whether we expect URLs to have a trailing slash or not. This PR is currently assuming that there will always be a trailing slash, but for users who have chosen not to have one (which is the default in SvelteKit) it's not really correct.

Perhaps Vite should accept base with or without a trailing slash so that the user can decide which they would prefer or add a new trailingSlash option similar to SvelteKit's

@JounQin
Copy link
Contributor Author

JounQin commented Jul 19, 2022

@benmccann It didn’t work at all previously so would it break SvelteKit?

Of course I agree we should support base without slash.

@benmccann
Copy link
Collaborator

benmccann commented Jul 19, 2022

SvelteKit historically hasn't used the publicDir and base options, but does its own static asset serving. I put together a branch to use Vite's implementation. I came across this PR while looking at what Vite's implementation does and wanted to make sure to mention it so that we don't bake in too many assumptions. I filed an issue regarding support without a slash: #9236

@JounQin
Copy link
Contributor Author

JounQin commented Aug 3, 2022

@sapphi-red Any progress on this?

@sapphi-red
Copy link
Member

No, I've put this in the team board but not discussed yet.

@benmccann benmccann mentioned this pull request Nov 1, 2022
9 tasks
@patak-cat patak-cat closed this in 8f87282 Nov 12, 2022
tony19 pushed a commit to tony19/vite-docs-template that referenced this pull request Nov 12, 2022
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Closes vitejs/vite#9236
Closes vitejs/vite#8770
Closes vitejs/vite#8772
docschina-bot pushed a commit to vitejs/docs-cn that referenced this pull request Nov 12, 2022
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Closes vitejs/vite#9236
Closes vitejs/vite#8770
Closes vitejs/vite#8772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

serve: with base: '/docs/', should /docs work as /docs/?

3 participants