mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
fix(E2E): Add cors package
This commit is contained in:
@@ -1,14 +1,7 @@
|
||||
import express, { NextFunction, Request, Response } from 'express';
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import { createServer as createViteServer } from 'vite';
|
||||
|
||||
const cors = (req: Request, res: Response, next: NextFunction) => {
|
||||
res.header('Access-Control-Allow-Origin', '*');
|
||||
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
||||
res.header('Access-Control-Allow-Headers', 'Content-Type');
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
async function createServer() {
|
||||
const app = express();
|
||||
|
||||
@@ -16,7 +9,7 @@ async function createServer() {
|
||||
const vite = await createViteServer({
|
||||
configFile: './vite.config.ts',
|
||||
server: { middlewareMode: true },
|
||||
appType: 'custom', // don't include Vite's default HTML handling middlewares
|
||||
appType: 'custom', // don't include Vite's default HTML handling middleware
|
||||
});
|
||||
|
||||
app.use(cors());
|
||||
|
Reference in New Issue
Block a user