Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
Please consider the following code (serverless.yml):
functions:
exportCvToPdf:
handler: handler.exportCvToPdf
timeout: 20
events:
- http:
path: export
method: post
Deploying to AWS returns a link to the API endpoint.
CURL'ing the endpoint returns:
{"message":"Missing Authentication Token"}
How can I make a public endpoint using Serverless Framework?
I have tried the following:
functions:
exportCvToPdf:
handler: handler.exportCvToPdf
timeout: 20
events:
- http:
path: export
method: post
authorizer: none # None NONE "none" "NONE" "None" has also been tried
The above returns an error at deploy:
Function none doesn't exist in this Service
You should be able to just omit authorizer and your endpoint will be publicly accessible right after deployment. Ensure that you're calling proper URL with proper path and method. Could you share how are you calling the deployed endpoint?
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 months ago.
Improve this question
i am using AWS API Gateway direct integrated to s3 to store any data to s3 .
i have enabled the CORS in S3 and api gateway , if i calling from postman or curl command its working fine and i can see i am getting response header Access-Control-Allow-Origin to *.
But when i am calling from vue js local machine alwys getting CORS error
Access to XMLHttpRequest at 'https://******/tests3/tryfinal44.txt' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
1 CORS Enabled in s3
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"PUT",
"POST"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [
"Access-Control-Allow-Origin"
]
}
]
2 Curl operation working fine
curl -X PUT ****/onemore1221.txt -d "testing the api" -i
3 Vue js calling code -
const article = "Vue POST Request Example" ;
const headers = {
"Content-Type":'text/plain'
};
axios.put("**/tests3/tryfinal44.txt", article, { headers })
.then((response) => {
console.log(response)
})
.catch(error => {
this.errorMessage = error.message;
console.error("There was an error!", error);
});
4 API setting
i tried with ajax ,same issue with ajax call also .
Any suggestion will be help full .
Thanks
Dilip
hi we able to solve this issue , after discussing with aws support , as problem was not with cors.
actual problem was with preflight request was giving 500 .with this error
error Execution failed due to configuration error: Unable to transform request
we figure out Binary media in api setting / was causing the problem in my case , i have changed to image/png and its started working .
Thanks for all help.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I have just moved a MERN Stack app to AWS and I'm currently facing some problems with the certificates.
Current Scenario:
My website (example.com) has Cloudflare as the DNS Management.
I have added Cloudflare's Full SSL (end-to-end) encryption and a page rule for always redirect to https.
On the AWS Side, I have an Application Load Balancer (ALB) which is having a listener for HTTPS:443 using the certificate provided by AWS CA for example.com.
Problem:
When making a call to example.com, it redirects me to https://example.com and renders the static page which is fine.
When I change the page to https://example.com/articles the website goes berserk and changes it to http://example.com/articles and the certificate sign shows insecure now! Although, I do get my articles response from the server. Moreover, this is only happening in chrome and not firefox!
I would be more than happy to share any details/images required to support my query.
Thanks in advance!
Please share your page rules here. Your page rules are getting problem for you.
You can use the Always Use HTTPS function provided without wasting your page rules.
I'm pretty excited about HTTP Gateways due to the drastically reduced pricing in comparison to REST Gateways, but I'm stuck on creating routes that do not completely blow up my serverless.yml file.
The documentation for HTTP Gateway at Serverless describes this to define routes:
functions:
params:
handler: handler.params
events:
- httpApi:
method: GET
path: /get/for/any/{param}
There is a support for '*', but this causes issues with OPTIONS cause those will overwrite the created CORS policies (so OPTIONS requests would actually get to the application, which does not make any sense, especially if the route is protected via an authorizer).
Also, it's not possible to define multiple methods.
# does not work
method: GET,POST,DELETE
# also not possible
method:
- GET
- POST
- DELETE
The only configuration I found is to define all routes separately:
events:
- httpApi:
path: /someApi/{proxy+}
method: GET
- httpApi:
path: /someApi/{proxy+}
method: POST
- httpApi:
path: /someApi/{proxy+}
method: DELETE
This works fine & the UI is even bundling the routes cause they're on the same prefixed path:
But with this I have to define all HTTP methods for all my main resources separately including the attached authorizer.
Is there some way to combine this?
I have enabled cache for one of the API configured in AWS API Gateway as per resource. The resource I created for this API are Proxy Resource as shown in image below -
Now the problem I am facing is for all urls same response (the one last cached) is returned, it does not matter if path are different. For example, /path/xyz and /path/xyz/p1 return same response. I suspect that as this API is proxy resource (pass-through), the default cache keys are not unique and hence same response for all urls. Enabling request parameters for cache key wont help here.
Has anyone faced this issue? Or am I missing some configuration?
Finally I got it working with the help of my colleague having expertise in AWS. It is simple and now I feel I should have given it try.
The answer to enable caching for those apis under resources as shown in image below -
The configuration which worked for me with proxy and solved the problem is with specifying every param I am using in template.yaml:
paths:
/{proxy+}:
get:
security:
- api_key: []
parameters:
- name: param_one
in: query
type: string
- name: param_two
in: query
type: string
requestParameters:
integration.request.querystring.param_one: method.request.querystring.param_one
integration.request.querystring.param_two: method.request.querystring.param_two
cacheKeyParameters:
- method.request.querystring.param_one
- method.request.querystring.param_two
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying to make a graph api call to post status update to a fan pages.
I am using http post here
my base url: https://graph.facebook.com/{page_id}/feed
message=hi&access_token={access_token}
I am however getting an error
{"error":{"message":"An unexpected error has occurred. Please retry your request later.","type":"OAuthException","code":2}}
Could you tell me if I am missing anything?
Things I checked:
Access token is valid
Page exisits
You need the extended permission manage_pages for your app (or through graph explorer) to be able to publish to the page feed. Once you have a new access_token with that permission, this should work:
curl \
-F "message=hi" \
"https://graph.facebook.com/<page_id>/feed"
Or whatever method you prefer.
Edit: You may also need the page access token, as described in the Publish page API
There was a genuine bug at Fb's end.