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

fix: apply middleware before internal middleware; add CORS support #7

Merged
merged 3 commits into from
Aug 10, 2024

Conversation

reifiedbeans
Copy link
Owner

Fixes #6

@reifiedbeans
Copy link
Owner Author

Build blocked on vitejs/vite#17836

@reifiedbeans
Copy link
Owner Author

Audited the other server middlewares used in Vite currently and determined that there shouldn't be any middleware other than CORS that this plugin should need to implement.

@reifiedbeans
Copy link
Owner Author

reifiedbeans commented Aug 10, 2024

Using the following code as a test sample, this change passes manual testing for resolution and CORS.

vite.config.ts

import { defineConfig } from "vite";
import serveStatic from "vite-plugin-serve-static";

export default defineConfig({
  plugins: [
    serveStatic([
      {
        pattern: /^\/test/,
        resolve: './test.json',
      },
    ]),
  ],
});

fetch.html

<!doctype html>
<html lang="en">
  <script>
    async function getTest() {
      const res = await fetch('http://localhost:5173/test');
      console.log(res);
    }
    void getTest();
  </script>
</html>

@reifiedbeans reifiedbeans marked this pull request as ready for review August 10, 2024 09:01
@reifiedbeans reifiedbeans merged commit 540b2a3 into main Aug 10, 2024
2 checks passed
@reifiedbeans reifiedbeans deleted the cors-fallback-fix branch August 10, 2024 09:02
Copy link

🎉 This issue has been resolved in version 1.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Regression in 1.0.2 breaking matches
1 participant