score:6
solution in my case was pretty easy.
i had to import oakcors into my deno api app.ts
import { oakcors } from "https://deno.land/x/cors/mod.ts";
after that, just add the excluded origin after app instantiation:
app.use(
oakcors({
origin: "http://localhost:3000"
}),
);
note: i tried to set origin to origin: false
and that did not work in my case.
for more options on deno cors here is a link: https://deno.land/x/cors
score:-3
placeapp.use(oakcors())
before your routes like this:
app.use(oakcors())
app.use(route.routes())
this is allow all cors before to manage the routes
score:2
for me, i had to first pass oakcors configuration to the app and then the routes.
app.use(oakcors({
origin: 'http://localhost:4200',
optionssuccessstatus: 200,
}));
app.use(router.routes());
score:2
this works just fine:
app.use(oakcors({ origin: "*" }));
Source: stackoverflow.com
Related Query
- Deno Oak Disable Cors
- How can I disable CORS for a single route in Express without rewriting all of my routes?
- How to disable options method from cors in get method
- How to disable a button when an input is empty?
- How to disable button in React.js
- How to disable ESLint react/prop-types rule in a file?
- Disable back button in react navigation
- Axios having CORS issue
- How to disable open browser in CRA?
- Disable ESLint that create-react-app provides
- How to disable source maps for React JS Application
- webpack dev server CORS issue
- react-router: How to disable a <Link>, if its active?
- Next js - disable server side rendering on some pages
- How to allow CORS in react.js?
- Disable Options on React-Native Text Input
- React Select disable options
- Disable Unnecessary escape character: \/ no-useless-escape
- Can I disable a View component in react native?
- Access to XMLHttpRequest at '...' from origin 'localhost:3000' has been blocked by CORS policy
- How to disable box-shadow globally for all MUI components?
- How to disable the hover effect of material-ui button inside of a styled component
- How can I disable all typescript type checking?
- Using JavaScript Axios/Fetch. Can you disable browser cache?
- Enable CORS in fetch api
- How to overcome the CORS issue in ReactJS
- Disable prettier for a single file
- Typescript eslint disable no-unused-vars
- Disable React.createClass and PropTypes deprecated warnings in babel react present
- Access to fetch at from origin 'http://localhost:3000' has been blocked by CORS policy
More Query from same tag
- Populating ReactJS HTML Form via Javascript
- Which of the following is the correct way to create links for the react components?
- How can I get pagination work on Meteor 1.5.2 with react?
- "Invisible Ink" text effect using JavaScript
- React js Performance tool addon throws "Cannot read property 'counts' of undefined"
- React async state management
- How to use dispatch Redux actions in a separate function scripts in React?
- How to upload image using ReactJS and save into local storage?
- calling useFetch hook inside useEffect
- Correctly positioning a Modal without restructuring code React
- how to make JavaScript cell take full row width
- React useState() hook does not update state when child.shouldComponentUpdate() returns false
- Calling a REST webservice from ReactJS
- DOM Element Returning Null on React
- React setState {} not setting variable
- Undefined prop value in child component
- Highlight code dynamically in React using hljs library
- how to redirect all server requests to index.html file in node.js
- How do I integrate React hook form with NumberFormat (react-number-format)?
- Access Formik's values outside of component | React
- Add class to correct option
- Component not rendering after using <Link> though the URL gets changed
- Permissions error when trying to install jquery-ui/data
- Adding loading state to map function causes items to display as loading
- How to configure multi language response of aws amplify?
- Getting a typeError in React saying this.props is not a function when child component tries to call passed function
- Cypress click on an nth image in a table with specifc src
- Using React-Spring useSprings only on active button in array
- BABEL parse error: transpiling react js into js
- React does not render correct on page refresh