Skip to content

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

Merged
typeparameter merged 3 commits into
mainfrom
cors-fallback-fix
Aug 10, 2024
Merged

fix: apply middleware before internal middleware; add CORS support#7
typeparameter merged 3 commits into
mainfrom
cors-fallback-fix

Conversation

@typeparameter
Copy link
Copy Markdown
Owner

Fixes #6

@typeparameter
Copy link
Copy Markdown
Owner Author

Build blocked on vitejs/vite#17836

@typeparameter
Copy link
Copy Markdown
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.

@typeparameter
Copy link
Copy Markdown
Owner Author

typeparameter 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>

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

🎉 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