• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

224
Views
Puerto de cambio de MSW (trabajador de servicio simulado) desde 8080

La documentación de MSW para request-url dice:

 // Only "POST https://api.backend.dev/users" requests match this handler rest.post('https://api.backend.dev/users', responseResolver) // Given your application runs on "http://localhost:8080", // this request handler URL gets resolved to "http://localhost:8080/invoices" rest.get('/invoices', invocesResolver)

He estado buscando mucho pero no puedo encontrar algunos documentos sobre cómo cambiar el puerto. Entonces podría ser algo como http://localhost:3001

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El "localhost:8080" se enfatiza arriba porque una URL relativa contra un localhost predeterminado se resolverá en localhost:8080/url . No necesariamente tienes que personalizar eso.

URL relativa

Cualquier URL relativa será relativa a la ubicación de la aplicación actual. Entonces, si su aplicación se ejecuta en http://localhost:3000 y definió un controlador de /user relativo, obtendrá http://localhost:3000/user automáticamente.

 // If my app runs on :3000, the handler above intercepts // a GET http://localhost:3000/user. I don't have to specify // hostnames/ports for relative URLs against the application address. rest.get('/user', resolver)

URL absoluta

Si necesita (por alguna razón) definir un controlador para un servicio localhost externo , el que no es su aplicación, incluya su URL absoluta:

 // My app runs on :3000 but I want to intercept and mock a request // to another app that runs on localhost:3001. Here's how I do it: rest.get('http://localhost:3001/user`, resolver)
about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error