Skip to content
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

cors header #32

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

cors header #32

wants to merge 5 commits into from

Conversation

rdavoli
Copy link

@rdavoli rdavoli commented Oct 23, 2020

Fixes #36

Overview

Changes for running the backend outside the cloud.

@rdavoli rdavoli requested a review from filipecorrea October 23, 2020 12:40
const signedProcessedText = await text.process(signed)

const translation = await retrieveData(language, 'translations', { signed: signedProcessedText.hash })

if (!translation) throw new NotFoundError()
Copy link
Contributor

Choose a reason for hiding this comment

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

It's important to keep this validation error.

Copy link
Author

Choose a reason for hiding this comment

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

In this case, shouldn't we just return no translation and let the backend handle this and show an alert to the user that no translation was found?

As our database is still small, most phrases will return no translation.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the backend repo and NotFoundError is equal to no translation was found.

@@ -47,6 +47,7 @@ module.exports = (req, res, next) => {
translations.retrieve(value.params.language, sanitize(value.query.text))
.then(response => {
res.locals = response
res.set('Access-Control-Allow-Origin', '*')
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried using localhost instead of *?

Copy link
Contributor

@filipecorrea filipecorrea left a comment

Choose a reason for hiding this comment

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

We should revert the changes on src/controllers/translations/retrieve.js, there's no need for those changes in this pull request.

ALLOWED_ORIGINS=http://localhost:3001
```


Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of setting ALLOWED_ORIGINS as mandatory, can we set it to http://localhost:3001 by default and move the update instruction to the Customize section bellow?

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