Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Enabled cors #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

AlenJoseph
Copy link

Hi,
I was creating a short URL service with openfaas , while integrating the function with react js front end, It showed

Access to fetch at 'http://192.168.99.100:31112/function/getstat' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled

. so I edited the templates which enable cors and it worked fine, so I thought it would be a good feature to add to the templates

@derek
Copy link

derek bot commented Jul 27, 2019

Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. That's something we need before your Pull Request can be merged. Please see our contributing guide.
Tip: if you only have one commit so far then run: git commit --amend --signoff and then git push --force.

@derek derek bot added the no-dco label Jul 27, 2019
@@ -7,7 +7,7 @@ const express = require('express')
const app = express()
const handler = require('./function/handler');
const bodyParser = require('body-parser')

const cors = require("cors");// imported cors package
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • comment not useful
  • prefer single quote

app.put('/*', middleware);
app.use(cors());// enabled cors
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use an instance Router instead of duplicating app.use(cors());

app.put('/*', middleware);
app.use(cors());// enabled cors
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same //

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants