Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
react-map-gl - La variable ambiental no pasa un token

SERVIDOR DE DESARROLLADOR si copio y pego mi token de API directamente en .env

 NEXT_PUBLIC_MAPBOX_API="my-secret-mapbox-gl-api-key"

y usarlo como

 mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_API}

y no muestra el mapa y hay un error en las herramientas de desarrollo

 next-dev.js?3515:24 Error: An API access token is required to use Mapbox GL. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes at t.RequestManager._makeAPIURL (mapbox-gl.js?0c80:31:423135) at t.RequestManager.normalizeStyleURL (mapbox-gl.js?0c80:31:420958) at ei.loadURL (mapbox-gl.js?0c80:35:102600) at Map._updateStyle (mapbox-gl.js?0c80:35:458753) at Map.setStyle (mapbox-gl.js?0c80:35:458172) at new Map (mapbox-gl.js?0c80:35:448583) at Mapbox._initialize (mapbox.js?699b:222:1) at new Mapbox (mapbox.js?699b:128:1) at eval (map.js?48e9:61:1)

Traté de ejecutar un servidor de desarrollo nuevamente, no ha ayudado

Uso "siguiente": "12.2.2".

¿mmm? También probé REACT_APP_MAPBOX_ACCESS_TOKEN en lugar de NEXT_PUBLIC y luego, en el componente Map , el accesorio: mapboxAccessToken={process.env.REACT_APP_MAPBOX_ACCESS_TOKEN} ¡y todavía no ha ayudado! :/

 <Map initialViewState={{ longitude: 21.338631, latitude: 50.102242, zoom: 11, }} style={{ overflow: "hidden", }} mapStyle={mapboxThemeStyle} mapboxAccessToken="my-secret-api-token-without-env-and-it-works" // id="map" tabIndex="-1" > <Marker longitude={21.338631} latitude={50.102242} color="#206ea0" /> </Map>

¡Intenté agregar env a .env.local como NEXT_PUBLIC_MY_MAPBOX_API_TOKEN="pk.xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxx-xxxxxxxxxx" y funciona! ¡Gracias @Heet Vakharia!

reaccionar-mapa-gl: https://github.com/visgl/react-mapa-gl

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

De acuerdo con los documentos de Next.JS para envs en Frontend, debe agregar sus envs en el archivo .env.local y All ENVS debe comenzar con NEXT_APP_ (que ya ha hecho) y luego no olvide reiniciar la aplicación en la terminal

https://nextjs.org/docs/basic-features/environment-variables

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!