CORS headers
See original GitHub issueПривет, я использую приложение на vue как тестовое, которое притворяется Алисой и отправляет запросы на навык.
Проблема в том, что post запросы из браузера не проходят, из-за отсутствия CORS заголовков в ответе yandex-dialogs-sdk.
Возможно ли сделать возможность указать заголовки, не меняя код sdk?
Я пока что прямо в alice.js listen вписал:
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
next();
})
Это помогло, но хочется по-нормальному сделать. Я вижу, что в alice.js есть middlewares, но они не используются, они предполагались как раз для таких случаев? Если да, могу отправить PR с доделкой этого функционала.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Cross-Origin Resource Sharing (CORS) - MDN Web Docs
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, ...
Read more >Cross-origin resource sharing - Wikipedia
Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the...
Read more >CORS and the Access-Control-Allow-Origin response header
The CORS specification identifies a collection of protocol headers of which Access-Control-Allow-Origin is the most significant. This header is returned by a ...
Read more >django-cors-headers - PyPI
Adding CORS headers allows your resources to be accessed on other domains. It's important you understand the implications before adding the headers, since...
Read more >CORS Enabled - W3C Wiki
For IIS6 · Open Internet Information Service (IIS) Manager · Right click the site you want to enable CORS for and go to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
По убыванию нормальности :
Проще всего открыть доступ к экземпляру express, чтобы напрямую ему делать use, а мидлвари согласен, лучше оставить для ctx. По сути, если твой sdk выставляет правильные заголовки с точки зрения Яндекса, то сложно придумать, зачем еще это может понадобиться, кроме как для отключения CORS на время тестирования.
Если правда других использований express не приходит в голову, можно сделать какой-нибудь флаг специально для этой фичи, например,
alice.disableCORS()
.Можно вообще по умолчанию отключать CORS по условию
process.env.NODE_ENV != 'production'
@popstas our new webhook server is implemented on pure
http
module to add CORS support you can easily use your own server, e.gexpress
how to do CORScors
(npm install cors
)