“CORS Header hilang Vue API Gateway” Kode Jawaban

CORS Header hilang Vue API Gateway

1# serverless.yml
2
3...
4
5		resources:
6		  Resources:
7		    GatewayResponseDefault4XX:
8		      Type: 'AWS::ApiGateway::GatewayResponse'
9		      Properties:
10		        ResponseParameters:
11           gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
12           gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
13		        ResponseType: DEFAULT_4XX
14		        RestApiId:
15		          Ref: 'ApiGatewayRestApi'
16		```
Weary Whale

CORS Header hilang Vue API Gateway

1'use strict';
2
3module.exports.getProduct = (event, context, callback) => {
4
5  // Do work to retrieve Product
6  const product = retrieveProduct(event);
7
8  const response = {
9    statusCode: 200,
10    headers: {
11      'Access-Control-Allow-Origin': '*',
12      'Access-Control-Allow-Credentials': true,
13    },
14    body: JSON.stringify({
15      product: product
16    }),
17  };
18
19  callback(null, response);
20};
21
22module.exports.createProduct = (event, context, callback) => {
23
24  // Do work to create Product
25  const product = createProduct(event);
26
27  const response = {
28    statusCode: 200,
29    headers: {
30      'Access-Control-Allow-Origin': '*',
31      'Access-Control-Allow-Credentials': true,
32    },
33    body: JSON.stringify({
34      product: product
35    }),
36  };
37
38  callback(null, response);
39};
Weary Whale

Jawaban yang mirip dengan “CORS Header hilang Vue API Gateway”

Pertanyaan yang mirip dengan “CORS Header hilang Vue API Gateway”

Lebih banyak jawaban terkait untuk “CORS Header hilang Vue API Gateway” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya