Open Phok7 opened 9 months ago
Hello, @Phok7 and appreciate your patience on a response here. Is this specifically happening when you're trying to make Auth API calls on your deployed app? Are you applying custom headers on Amplify and could you possibly share your app id too?
@Phok7, wanted to follow up again with another suggestion if you're still experiencing this. Can you also check to see if you've enabled CORS for your endpoints?
Hello @cwomack and sorry for the wait.
Hello, @Phok7 and appreciate your patience on a response here. Is this specifically happening when you're trying to make Auth API calls on your deployed app? Are you applying custom headers on Amplify and could you possibly share your app id too?
Yes, only happens in deployed apps, because of the Amplify rewrite rule.
I don't know what you mean with if I can share the app id, sorry.
I'm using this custom headers:
customHeaders:
- pattern: '**'
headers:
- key: api_key
value: ********
- key: Access-Control-Allow-Origin
value: '*'
But doesn't works...
@Phok7, wanted to follow up again with another suggestion if you're still experiencing this. Can you also check to see if you've enabled CORS for your endpoints?
The endpoints are from a third party API and I can't enable CORS.
The problem is that Amplify prevents Angular from running its own proxy since the request first goes through Amplify's rewrite rule and does not reach the Angular proxy.
Thanks @cwomack, I appreciate your help.
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication, REST API, GraphQL API
Amplify Version
v6
Amplify Categories
auth, function, api
Backend
Amplify CLI
Environment information
Describe the bug
Hello, I have an Angular app which requires to make externals API calls, the method to do this is with an Angular proxy like that:
The proxy.conf.json file look like that:
And in the angular.json config I have the "proxyConfig" rule configured in the "serve" section, all works fine in my local enviroment.
Then in the Amplify Rewrites and redirects section I add this rule:
Source address: /aemet/<> Target address: https://opendata.aemet.es/opendata/<> Type: 301 (Redirect - Permanent)
The problems occurs when y deploy the app, what happens is that I ever get an CORS error due to the Angular proxy is not working because the Amplify redirection override this.
There are any way to solve this issue removing the Rewrite rule or something similar?
I have try everything, adding the Angular proxy, removing, adding Amplify Rewrites and removing, changing the Type of the redirection... but nothing works.
If I use Postman works fine but the problem is with the Angular app, because the request is made by de HttpClient library of Angular and is sent over a browser, if the Angular proxy may works, no problems should occurs.
Thanks.
Expected behavior
The app should use the Angular proxy configuration instead of use the Amplify rewrite rule.
Reproduction steps
Code Snippet
Log output
aws-exports.js
/ eslint-disable / // WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = { "aws_project_region": "us-east-1", "aws_cloud_logic_custom": [ { "name": "AdminQueries", "endpoint": "https://xxxxxxxxxxxx", "region": "us-east-1" } ], "aws_appsync_graphqlEndpoint": "http://192.168.1.26:20002/graphql", "aws_appsync_region": "us-east-1", "aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS", "aws_appsync_dangerously_connect_to_http_endpoint_for_testing": true, "aws_cognito_identity_pool_id": "us-east-1:xxxxxxxxxxx", "aws_cognito_region": "us-east-1", "aws_user_pools_id": "us-east-1_xxxxxxxxxxx", "aws_user_pools_web_client_id": "xxxxxxxxxxxxx", "oauth": {}, "aws_cognito_username_attributes": [ "EMAIL" ], "aws_cognito_social_providers": [], "aws_cognito_signup_attributes": [ "EMAIL" ], "aws_cognito_mfa_configuration": "OFF", "aws_cognito_mfa_types": [ "SMS" ], "aws_cognito_password_protection_settings": { "passwordPolicyMinLength": 8, "passwordPolicyCharacters": [] }, "aws_cognito_verification_mechanisms": [ "EMAIL" ] };
export default awsmobile;
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response