Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

307
Vistas
PHP file in React public folder(Testing on localhost)

Currently I am working on a React folder with some PHP in public folder.

Structure

.
├── pubic
│   ├── api
│        └── co.php
├── _src
│   ├── api
│   └── components
│   └── index.tsx
├── package.json
└── node_modules

The public folder contains PHP files that changes Requests/Responses to client/API server(made by diff company).

I added another endpoint/PHP file in public folder but cannot seem to access it when testing on localhost. My coworker has mentioned that I need to update changes in staging server to test out changes in PHP folder.

Is there a better way to test locally so I do not have to update server everytime I make changes in public folder adding PHP files?

/src/api/co/reg/index.ts

import { TRequestConfig, TRequestParams } from '../..';
export { CoRes } from './CoRes.class';

export const coRequestConfig: TRequestConfig = {
  endpoint: '/tempo/api/co.php',
  method: 'POST',
  useMock: false,
  mockFunc: params => {
    return {
      ok: true,
      body: '{}',
    };
  },
  params2request: (params): TRequestParams => {
    return {
      body: params ? params.body : {},
    };
  },
};

/public/api/co.php

<?php
$ch = curl_init();
$isDev = $_SERVER['SERVER_NAME'] === 'stg.cooo.ca' || $_SERVER['SERVER_NAME'] === 'lol.ca';
$protocol = $isDev ? 'https://cooo.com' : 'https://cooo.prod.com';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $url = "${protocol}/aa/api/co/used";
  $data = file_get_contents('php://input');

  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

} else {
  $couponId = $_GET['couponId'];  
  $url = "${protocol}/aa/api/co/${couponId}";

  curl_setopt($ch, CURLOPT_URL, $url);
}
if ($isDev) {
  curl_setopt($ch, CURLOPT_USERPWD, "1234:1122"); 
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo  $result;

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda