using node"s hapi framework, API service. Then request the API to have a cross-domain problem through ajax in a project.
route.options.cors
Default value: false (no CORS headers).
The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. To enable, set cors to true
this is a hapi document. Open this to allow cross-domain requests from ajax.
in fact, it is possible to send ajax"s get request successfully. As shown in the figure
PUT :
MIME type application/json
.
ajax
found that the request has been allowed.
returns 500 because my API accepts parsing by json. For example, the value of id under user is obtained by this.request.payload.User.id
. But if the data is in x-www-from format, change it to this.request.payload.User [id]
to get.
I want to know what went wrong with this put request to send json data that was not allowed.