Enable CORS in vespa

ぃ、小莉子 提交于 2020-01-05 03:57:09

问题


How to enable CORS in vespa? I want to deploy my API's to swagger UI but due to CORS disbled in vespa, I am unable to do this. Is there any way to enable CORS in vespa or How should I use API's in swagger to use it? Please help.


回答1:


Vespa does not come with built-in CORS support. You'll have to implement the CORS logic yourself as JDisc security filters (http-server-and-filters.html, services-http.html#filter).

The Vespa source code contains a set of CORS filters that can be used as inspiration. You can technically use them, but they are not public API and can be changed/removed in the future.

You will need two filters:

  • A request filter handling CORS preflight HTTP requests
  • A response filter that appends CORS headers to HTTP responses

Note that the response filters are not invoked if a request filter returns a response. Any other JDisc filters in your application must therefore include the CORS headers when they return a response.

See http-server-and-filters.html#set-up-filter-chains on how to configure request/response filter chains.



来源:https://stackoverflow.com/questions/53810631/enable-cors-in-vespa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!