{"library":"micro-cors","title":"Simple CORS Middleware for Micro","description":"micro-cors is a straightforward middleware designed to enable Cross-Origin Resource Sharing (CORS) for applications built with `micro`, a minimalist asynchronous HTTP microservices framework. The package's current stable version is `0.1.1`, which was last published approximately seven years ago. While `1.0.0-alpha` versions were released around five years ago, indicating a past attempt at a major update, development appears to have stalled in alpha, leaving the `0.x` branch as the de facto stable release. It maintains a slow release cadence, essentially being in a maintenance mode. Its key differentiator is its small footprint and specific integration with the `micro` ecosystem, aiming for minimal configuration to handle CORS headers.","language":"javascript","status":"maintenance","last_verified":"Wed Apr 22","install":{"commands":["npm install micro-cors"],"cli":null},"imports":["import microCors from 'micro-cors';\nconst cors = microCors();","const cors = require('micro-cors')();","const cors = microCors({ allowMethods: ['GET', 'POST'] });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { send } from 'micro';\nimport microCors from 'micro-cors';\n\nconst cors = microCors({\n  allowMethods: ['GET', 'POST', 'OPTIONS'],\n  allowHeaders: ['X-Requested-With', 'Access-Control-Allow-Origin', 'X-HTTP-Method-Override', 'Content-Type', 'Authorization', 'Accept'],\n  origin: '*'\n});\n\nconst handler = async (req, res) => {\n  if (req.method === 'OPTIONS') {\n    // Handle preflight requests explicitly if needed\n    return send(res, 200, 'ok!');\n  }\n  \n  if (req.method === 'POST') {\n    // Example POST request handling\n    const data = await json(req);\n    return send(res, 200, { message: 'Received POST data', data });\n  }\n\n  // Default GET response\n  return send(res, 200, { message: 'Hello from micro-cors!' });\n};\n\nexport default cors(handler);","lang":"javascript","description":"Demonstrates setting up `micro-cors` with a basic `micro` handler, including options for allowed methods and explicit handling for CORS preflight requests.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}