Skip to content

Fixed some issues in relation to http headers, profile links and proxies #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 12, 2020

Conversation

sammychinedu2ky
Copy link
Contributor

Added links to the profile sections of teams in the https://www.codeuino.org/#/team
Fixed issue in the netlify functions. The callback keyword wasn't needed since the async keyword was used and this made it return Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
So I resolved these issues

@netlify
Copy link

netlify bot commented Sep 8, 2020

Deploy preview for codeuino processing.

Building with commit 4f68ea2

https://app.netlify.com/sites/codeuino/deploys/5f5c875817de2b00070645ce

@sammychinedu2ky
Copy link
Contributor Author

sammychinedu2ky commented Sep 8, 2020

I changed various props name to standard version which removes most errors during development. For instance, changed tabindex to TabIndex and class to className.
I edited the package.json file to use the lambda server after building the site locally (npm run build and npm run start). This ensures that you get to test the local version of netlify function after building your site.
I also set a proxy that points "localhost:9000" to "/.netlify/functions" this ensures that the netlify preview renders properly with the tweets in the preview mode.
here is the preview link generated https://deploy-preview-220--codeuino.netlify.app/#/

@sammychinedu2ky sammychinedu2ky changed the title Fixed some issues in relation to http headers and profile links Fixed some issues in relation to http headers, profile links and proxies Sep 9, 2020
Copy link
Contributor Author

@sammychinedu2ky sammychinedu2ky left a comment

Choose a reason for hiding this comment

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

made comments to the areas where I made changes

@@ -1,14 +1,14 @@
const axios = require("axios");
const xml2js = require("xml2js");

exports.handler = async (event, context, callback) => {
Copy link
Contributor Author

@sammychinedu2ky sammychinedu2ky Sep 9, 2020

Choose a reason for hiding this comment

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

The callback wasn't needed since the async keyword was used. This helps prevent some errors

const mediumURL = "https://medium.com/feed/codeuino";
try {
const response = await axios.get(`${mediumURL}`);
const data = response.data;
xml2js.parseString(data, (err, result) => {
const sendthis = result.rss.channel[0].item.slice(0, 3);
callback(null, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

had to use the return keyword because the async keyword was used to instantiate the function

@@ -53,7 +54,7 @@
"scripts": {
"lambda-serve": "netlify-lambda serve netlify-functions",
"heroku-postbuild": "npm run build",
"start": "serve -s build -l 3000",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed to also run the lambda function to ensure communication to serverless function is possible

@@ -1,3 +1,2 @@
export default process.env.NODE_ENV === "development"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

had to use "/.netlify/functions" because a proxy file was created

Comment on lines -16 to -50
linkedin: ""
linkedin: "https://www.linkedin.com/in/jaskiratsingh2000/"
},
{
name: "Devesh",
post: "Donut Maintainer",
headline:
"foss contributor|board member@CODEUINO|software engineer@SHAW ACADEMY|ex-intern@SHAW ACADEMY|HASURA| INTERNSHALA|HIREINK|INDICIUMHUB|",
profile: devesh,
github: "",
linkedin: ""
github: "https://github.com/devesh-verma",
linkedin: "https://www.linkedin.com/in/devesh-verma/"
},
{
name: "Vaibhav D. Aren",
post: "Board Member",
headline:
"SDE at HashedIn | GSOC 2018 Developer @SugarLabs | GSOC-19 Mentor @JBOSS(Codeuino)| GCI -18 Mentor @SugarLabs .",
profile: vaibhav,
github: "",
linkedin: ""
github: "https://github.com/vaibhavdaren",
linkedin: "https://www.linkedin.com/in/vaibhavdaren/"
},
{
name: "Ayush Nagar",
post: "CodeBadge Maintainer",
headline: "Student Mentor at Google Code-in",
profile: "https://avatars1.githubusercontent.com/u/32647423?s=460&v=4",
github: "https://github.com/ayushnagar123",
linkedin: ""
linkedin: "https://www.linkedin.com/in/ayushnagar123/"
},
{
name: "Siddharth",
post: "Designer",
headline: "Student Mentor at Google Code-in",
profile: "https://avatars1.githubusercontent.com/u/33068322?s=460&v=4",
github: "",
linkedin: ""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added profile links for GitHub and LinkedIn

@vaibhavdaren
Copy link
Member

@sammychinedu2ky can you resolve these conflicts

Comment on lines +1 to +13
const {createProxyMiddleware} = require('http-proxy-middleware')
// this proxy code allows the use of .netlify/function in both development and production
module.exports = function(app){
app.use(
createProxyMiddleware(
"/.netlify/functions", {
target: "http://localhost:9000",
pathRewrite: {
'^/\\.netlify/functions': ''
}
}
)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Proxy file to redirect all request from /.netlify/functions to http://localhost:9000 .
This ensures that netlify function works in both build state of local project and the preview mode of netlify during a pull request

@vaibhavdaren vaibhavdaren merged commit 84fa2fe into codeuino:development Sep 12, 2020
ksraj123 pushed a commit to ksraj123/website-www.codeuino.org that referenced this pull request Sep 25, 2020
accepted change

change to package.json

set the key prop properly

centered headers

added key prop

proxy:localdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants