I’m working with <https://github.com/JetBrains/cre...
# javascript
p
I’m working with https://github.com/JetBrains/create-react-kotlin-app and have to enable CORS, but cannot figure out how. What I have tried so far, was placing a webpack config js file in the root directory with this content:
Copy code
headers: {'Access-Control-Allow-Origin': '*'}
Anyone knows how to configure this properly?
g
What's the purpose for enabling CORS? Is it something you could do instead with the webpack
proxy
configuration?
p
Want to grab some data from another service via axio. Maybe the proxy configuration helps also out of here:
Copy code
private fun <T> sendQuery(query: String, handler: (List<T>) -> Unit) {
        axios<Neo4JResultList<T>>(settings(query)).then { response ->
            handler(extractData(response.data))
        }
    }

    private fun settings(path: String): AxiosConfigSettings {
        return jsObject {
            url = "<http://localhost:8080/movies/$path>"
            method = "GET"
            headers = buildHeaders()

        }
    }
So proxying would be also fine, but I do not know how to configure webpack in
create-react-kotlin-app
code structure.
g
I'm not sure about that either, I found this article though for more info about webpack proxy: https://www.avitzurel.com/blog/2016/07/19/using-webpack-to-proxy-to-your-local-web-server-to-avoid-cross-site-errors/