vite-plugin-html: Version 3 breaks vite proxy

In version v2.7.13 all worked fine, after upgrading to v3 (3.0.6) vite server proxy settings do work anymore if accessed directly via browser. Lets say I have in my vite config:

server: {
	proxy: {
		'/api': 'http://localhost:3000'
	},
}

calling localhost:8000/api/list directly from my browser always serves index.html only async XHR calls after initial load goes through the proxy.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 13
  • Comments: 21

Most upvoted comments

I also have same issue. And trying to remove below lines, it works fine. https://github.com/vbenjs/vite-plugin-html/blob/841d4ef04c3cf5ff0d4339350ae336aa83aa70ed/packages/core/src/htmlPlugin.ts#L87-L93

I don’t clearly understand why these lines are needed. (maybe, history mode support for vue-router ?) Can’t we remove this?

Also have this problem, and tested locally that this fix does indeed work:

https://github.com/vbenjs/vite-plugin-html/pull/96

@anncwb mind taking a look at the PR?

same problem, any progress now?

It looks like this change was fixed in release 3.2.0. @anncwb or @xrado can we get this issue closed.

still not working.

still doesn’t solve the issue for me. Vite proxy settings are still overridden by the plugin on the initial load of the page. Lets say I want to open api endpoint url in the new tab to see the response, instead of the response index.html loads.

PR welcome

same problem