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

Add proxy configuration to avoid CORS restrictions #34

Closed
FredrikAugust opened this issue Feb 18, 2021 · 1 comment · Fixed by #35
Closed

Add proxy configuration to avoid CORS restrictions #34

FredrikAugust opened this issue Feb 18, 2021 · 1 comment · Fixed by #35
Assignees
Labels
enhancement New feature or request
Projects

Comments

@FredrikAugust
Copy link
Contributor

I got it to work with using proxies on frontend.

Steps to reproduce:

  • Add to package.json:
    "proxy": "http://localhost:5000",
  • Code used for testing
            <button
                onClick={() =>
                    fetch('/graphql', {
                        method: 'POST',
                        headers: { 'Content-Type': 'application/json' },
                        body: `{"operationName":null,"variables":{},"query":"{ forecast { forecastGeometry { coordinates } } } "}`,
                    })
                }
            >
                test
            </button>

Remember that when proxying you need to make a request to the host you're serving the app from. This is done by default when omitting the host in the fetch request, and only including the path.

Originally posted by @FredrikAugust in IT2901-SINTEF01/backend#29 (comment)

@FredrikAugust FredrikAugust added the enhancement New feature or request label Feb 18, 2021
@FredrikAugust FredrikAugust added this to To do in Overview via automation Feb 18, 2021
@FredrikAugust FredrikAugust added this to the [User Story] Dashboard milestone Feb 18, 2021
@FredrikAugust FredrikAugust moved this from To do to In progress in Overview Feb 18, 2021
@blauks
Copy link
Contributor

blauks commented Feb 18, 2021

Nice, thanks for the help!:)

Overview automation moved this from In progress to Done Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

2 participants