-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Cross Origin Error (Vite 3.0.0-beta.10) #9059
Comments
🤯 This repo takes up 4.3GB on the disk… |
So it's related to this: #8543 |
Oh, thanks for debugging! I was not expecting someone to actually run the repo. Didn't know it was 4.3GB, that's huge. Anyway, I guess we need to do this automatically under the hood (in Cypress). Also probably here https://github.com/cypress-io/cypress/blob/lmiller/21381-react-18-with-ignore/npm/vite-dev-server/src/plugins/cypress.ts#L78 should be Thanks! Will close this. |
This actually isn't working for me - I just tried it. I still see the error. Hm. Weird. I'll explore a bit more. Edit: Vite 3 works great in my projects - the problem is isolated to Cypress repo, we do lots of weird things, I think there's no bug. |
Things may vary depending on your Node.js version (16 vs 18). See https://vitejs.dev/config/server-options.html#server-host |
What version of Node were you running when you saw this passing locally? I'm not having any luck (16 or 18). Thank you for the guidance so far. Vite 3 works great with other projects, I'm pretty sure we do something specific that's messing things up. That said, I'm surprised you were able to see this passing locally at all. |
🤦♂️ I really should've uploaded a full diff when I fixed the tests… Turns out I almost got it right… But it's actually another accidental change that I made in my local repo that fixed the issue. |
diff --git a/npm/vite-dev-server/cypress/e2e/react.cy.ts b/npm/vite-dev-server/cypress/e2e/react.cy.ts
index 6b7a3434ea..c5cd2e444f 100644
--- a/npm/vite-dev-server/cypress/e2e/react.cy.ts
+++ b/npm/vite-dev-server/cypress/e2e/react.cy.ts
@@ -21,7 +21,7 @@ for (const project of VITE_REACT) {
cy.startAppServer('component')
})
- it('should mount a passing test', () => {
+ it.only('should mount a passing test', () => {
cy.visitApp()
cy.contains('App.cy.jsx').click()
cy.waitForSpecToFinish()
diff --git a/npm/vite-dev-server/src/plugins/cypress.ts b/npm/vite-dev-server/src/plugins/cypress.ts
index 4ba23ad3ae..8de5ca0b4a 100644
--- a/npm/vite-dev-server/src/plugins/cypress.ts
+++ b/npm/vite-dev-server/src/plugins/cypress.ts
@@ -71,11 +71,10 @@ export const Cypress = (
configureServer: async (server: ViteDevServer) => {
server.middlewares.use(`${base}index.html`, async (req, res) => {
let transformedIndexHtml = await server.transformIndexHtml(base, '')
- const viteImport = `<script type="module" src="${options.cypressConfig.devServerPublicPathRoute}/@vite/client"></script>`
// If we're doing cy-in-cy, we need to be able to access the Cypress instance from the parent frame.
if (process.env.CYPRESS_INTERNAL_VITE_OPEN_MODE_TESTING) {
- transformedIndexHtml = transformedIndexHtml.replace(viteImport, `<script>document.domain = 'localhost';</script>${viteImport}`)
+ transformedIndexHtml = transformedIndexHtml.replace('<title>', `<script>document.domain = 'localhost';</script><title>`)
}
return res.end(transformedIndexHtml)
diff --git a/system-tests/projects/vite-3-react/package.json b/system-tests/projects/vite-3-react/package.json
index 74aa83cf34..b45b5f904b 100644
--- a/system-tests/projects/vite-3-react/package.json
+++ b/system-tests/projects/vite-3-react/package.json
@@ -5,7 +5,7 @@
},
"devDependencies": {
"@cypress/vite-dev-server": "file:../../../npm/vite-dev-server",
- "vite": "3.0.0-beta.10"
+ "vite": "3.0.0"
},
"projectFixtureDirectory": "react"
}
diff --git a/system-tests/projects/vite-3-react/yarn.lock b/system-tests/projects/vite-3-react/yarn.lock
index 6811d1e3ec..f7a809ed08 100644
--- a/system-tests/projects/vite-3-react/yarn.lock
+++ b/system-tests/projects/vite-3-react/yarn.lock
@@ -308,10 +308,10 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
-[email protected]:
- version "3.0.0-beta.10"
- resolved "https://registry.yarnpkg.com/vite/-/vite-3.0.0-beta.10.tgz#80d62a81a15bb755ca7d304cc0a56281acaec2be"
- integrity sha512-QtzSQVuhNLDp9j4wNdVT3aDyWyvoAL4QxBU/lnMyEKqTzYrXdqyHpFmfWW/wo/0uTluZKzbsUm89eQq2RxiKMg==
+[email protected]:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/vite/-/vite-3.0.0.tgz#b4675cb9ab83ec0803b9c952ffa6519bcce033a7"
+ integrity sha512-M7phQhY3+fRZa0H+1WzI6N+/onruwPTBTMvaj7TzgZ0v2TE+N2sdLKxJOfOv9CckDWt5C4HmyQP81xB4dwRKzA==
dependencies:
esbuild "^0.14.47"
postcss "^8.4.14"
The fix that actually worked is in this file: - transformedIndexHtml = transformedIndexHtml.replace(viteImport, `<script>document.domain = 'localhost';</script>${viteImport}`)
+ transformedIndexHtml = transformedIndexHtml.replace('<title>', `<script>document.domain = 'localhost';</script><title>`) The change in Vite 3 causing this issue is: #6901 |
It's landed in |
Sorry, forgot to post - I tracked it down to the exact same change :) thanks! |
Describe the bug
Hi,
We use Vite for development in Cypress, and as part of the Component Testing product. We build
@cypress/vite-dev-server
to facilitate Component Testing with Vite as a dev server.I'm excited for Vite 3, and tried it out. I'm running into this error, that I didn't previously see in Vite 2:
I'm not expecting the Vite team to fix this for me, more looking for info on
I included a reproduction, but it's not exactly minimal, since it needs our dev-server and surrounding code to reproduce.
I can look to make a more minimal one if needed, but if someone more familiar with Vite's code could suggest what might be leading to this problem, I can either patch it and/or work around it myself.
I'm guessing this isn't a straight up bug, but a side effect or some internals we are relying on. Hoping to figure something out before we move Vite to 3.0.0.
Reproduction
cypress-io/cypress#22748
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: