Skip to content

cors header#32

Open
rdavoli wants to merge 5 commits into
masterfrom
localbackend
Open

cors header#32
rdavoli wants to merge 5 commits into
masterfrom
localbackend

Conversation

@rdavoli

@rdavoli rdavoli commented Oct 23, 2020

Copy link
Copy Markdown

Fixes #36

Overview

Changes for running the backend outside the cloud.

@rdavoli rdavoli requested a review from filipecorrea October 23, 2020 12:40

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

if (!translation) throw new NotFoundError()

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/routes/translate/get.js Outdated
translations.retrieve(value.params.language, sanitize(value.query.text))
.then(response => {
res.locals = response
res.set('Access-Control-Allow-Origin', '*')

Copy link
Copy Markdown
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 *?

@filipecorrea filipecorrea left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread README.md
ALLOWED_ORIGINS=http://localhost:3001
```


Copy link
Copy Markdown
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