1"use strict";(self.webpackChunkdoc=self.webpackChunkdoc||[]).push([[5879],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var r=n(7294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=r.createContext({}),p=function(e){var t=r.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return r.createElement(s.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},d=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,s=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),d=p(n),m=a,g=d["".concat(s,".").concat(m)]||d[m]||u[m]||i;return n?r.createElement(g,o(o({ref:t},c),{},{components:n})):r.createElement(g,o({ref:t},c))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=d;var l={};for(var s in t)hasOwnProperty.call(t,s)&&(l[s]=t[s]);l.originalType=e,l.mdxType="string"==typeof e?e:a,o[1]=l;for(var p=2;p<i;p++)o[p]=n[p];return r.createElement.apply(null,o)}return r.createElement.apply(null,n)}d.displayName="MDXCreateElement"},1364:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>o,default:()=>u,frontMatter:()=>i,metadata:()=>l,toc:()=>p});var r=n(7462),a=(n(7294),n(3905));const i={},o="CORS (Cross-Origin Resource Sharing)",l={unversionedId:"api-plugin/cors",id:"api-plugin/cors",title:"CORS (Cross-Origin Resource Sharing)",description:"CORS, or Cross-Origin Resource Sharing, is an important web security feature that allows servers to control which domains can access their resources. It mitigates potential security risks by restricting unauthorized access to server resources.",source:"@site/docs/api-plugin/cors.mdx",sourceDirName:"api-plugin",slug:"/api-plugin/cors",permalink:"/docs/api-plugin/cors",draft:!1,editUrl:"https://github.com/Canner/vulcan-sql/tree/main/packages/doc/docs/api-plugin/cors.mdx",tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Offset",permalink:"/docs/api-plugin/pagination/offset"},next:{title:"Rate Limit",permalink:"/docs/api-plugin/rate-limit"}},s={},p=[{value:"Usage",id:"usage",level:2},{value:"Settings",id:"settings",level:2},{value:"Options",id:"options",level:2}],c={toc:p};
1function u(e){let{components:t,...n}=e;return(0,a.kt)("wrapper",(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"cors-cross-origin-resource-sharing"},"CORS (Cross-Origin Resource Sharing)"),(0,a.kt)("p",null,"CORS, or Cross-Origin Resource Sharing, is an important web security feature that allows servers to control which domains can access their resources. It mitigates potential security risks by restricting unauthorized access to server resources."),(0,a.kt)("h2",{id:"usage"},"Usage"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-yaml",metastring:'title="vulcan.yaml"',title:'"vulcan.yaml"'},"cors:\n enabled: true\n options:\n origin: 'http://google.com'\n allowMethods: 'GET,HEAD,PUT'\n")),(0,a.kt)("h2",{id:"settings"},"Settings"),(0,a.kt)("table",null,(0,a.kt)("thead",{parentName:"table"},(0,a.kt)("tr",{parentName:"thead"},(0,a.kt)("th",{parentName:"tr",align:null},"Setting"),(0,a.kt)("th",{parentName:"tr",align:null},"Default"),(0,a.kt)("th",{parentName:"tr",align:null},"Type"),(0,a.kt)("th",{parentName:"tr",align:null},"Description"))),(0,a.kt)("tbody",{parentName:"table"},(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:null},"enabled"),(0,a.kt)("td",{parentName:"tr",align:null},"true"),(0,a.kt)("td",{parentName:"tr",align:null},"boolean"),(0,a.kt)("td",{parentName:"tr",align:null},"Enable or disable the ",(0,a.kt)("inlineCode",{parentName:"td"},"cors")," service")))),(0,a.kt)("h2",{id:"options"},"Options"),(0,a.kt)("table",null,(0,a.kt)("thead",{parentName:"table"},(0,a.kt)("tr",{parentName:"thead"},(0,a.kt)("th",{parentName:"tr",align:null},"Option"),(0,a.kt)("th",{parentName:"tr",align:null},"Default"),(0,a.kt)("th",{parentName:"tr",align:null},"Type"),(0,a.kt)("th",{parentName:"tr",align:null},"Description"))),(0,a.kt)("tbody",{parentName:"table"},(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:null},"origin"),(0,a.kt)("td",{parentName:"tr",align:null},"{request Origin header}"),(0,a.kt)("td",{parentName:"tr",align:null},"string or Function(ctx)"),(0,a.kt)("td",{parentName:"tr",align:null},"Origin for ",(0,a.kt)("inlineCode",{parentName:"td"},"Access-Control-Allow-Origin"))),(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:null},"allowMethods"),(0,a.kt)("td",{parentName:"tr",align:null},"'GET,HEAD,PUT,POST,DELETE,PATCH'"),(0,a.kt)("td",{parentName:"tr",align:null},"string"),(0,a.kt)("td",{parentName:"tr",align:null},"Allowed methods in the string: ",(0,a.kt)("inlineCode",{parentName:"td"},"GET"),", ",(0,a.kt)("inlineCode",{parentName:"td"},"HEAD"),", ",(0,a.kt)("inlineCode",{parentName:"td"},"PUT"),", ",(0,a.kt)("inlineCode",{parentName:"td"},"POST"),", ",(0,a.kt)("inlineCode",{parentName:"td"},"DELETE"),", and ",(0,a.kt)("inlineCode",{parentName:"td"},"PATCH"))))),(0,a.kt)("p",null,"VulcanSQL uses ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/koajs/cors"},(0,a.kt)("inlineCode",{parentName:"a"},"@koa/cors"))," to handle CORS. While it comes with reasonable default settings, you can customize the settings in ",(0,a.kt)("inlineCode",{parentName:"p"},"vulcan.yaml")," to better suit your needs."),(0,a.kt)("p",null,"You may refer to the ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/koajs/cors#corsoptions"},"@koa/cors")," documentation."))}u.isMDXComponent=!0}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.