Need help / sample code snippet to implement the typescript react code to connect to elastic-search server to push data to index

Need help / sample code snippet to implement the typescript react code to connect to elastic-search server to push data to index from kibana running on local, This may need to bypass proxy & SSL certificate.

Below code snippet is working on local :

export const TestPlug2App = ({ basename, notifications, http, navigation }: TestPlug2AppDeps) => {
  const indexName = 'test_index'; // Example index name, replace with your actual index name
  const endpoint = `http://localhost:9200/${indexName}/_doc`;

  const [formData, setFormData] = useState({
    acc_name: 'acc1',
    skill: 'xyz',
  });

  const handleSubmit = async (event: React.FormEvent) => {
    event.preventDefault();
    try {
      // Send POST request to Elasticsearch to save form data
      await http.post(endpoint, {
        body: JSON.stringify(formData),
        headers: {
          'Content-Type': 'application/json',
        },
      });

I want this to work for elasticsearch sever running on remote :

Example :

export const TestPlug2App = ({ basename, notifications, http, navigation }: TestPlug2AppDeps) => {
  const indexName = 'test_index'; // Example index name, replace with your actual index name
  const endpoint = `http://remotehost.domain.net:9200/${indexName}/_doc`;

  const [formData, setFormData] = useState({
    acc_name: 'acc1',
    skill: 'xyz',
  });

  const handleSubmit = async (event: React.FormEvent) => {
    event.preventDefault();
    try {
      // Send POST request to Elasticsearch to save form data
      await http.post(endpoint, {
        body: JSON.stringify(formData),
        headers: {
          'Content-Type': 'application/json',
                    // Add your authentication token or credentials here
          // For example, if using basic authentication:
          'Authorization': 'Basic ' + btoa('username:Password')
        },
      });

Below is the working curl command for remote :

Sunils-MacBook-Pro:kibana sunil$ curl -u username:password -k -X POST https://remotehost.domain.net/sample_jp_test_index/_doc -H 'Content-Type: application/json' -d '{ "acc_name": "Test_Account_1", "skill": "Skill_1" }'

{"_index":"sample_jp_test_index","_type":"_doc","_id":"1iwASo8BO8gkgOVa5ffK","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}

Sunils-MacBook-Pro:kibana sunil$