Comments (10)
Yeap solved it using,
global.XMLHttpRequest = require("xhr2");
You can do this in your _app.ts if you are using nextjs@12 or in layout.tsx
if you are using nextjs@13
from mapbox-gl-directions.
Hi, I have the same issue with angular, I tried what you did with xhr2 dependency but it doesn't work for me.
If anyone has a solution, that would be great
from mapbox-gl-directions.
@spencerjsmall could you show some code on how you fixed this? Using Nextjs and having the exact same issue.
from mapbox-gl-directions.
@renzik At the top of dist/mapbox-gl-directions.js I included var xhr = require('xhr2')
, then replaced the three or so XMLHttpRequests with xhr
. This didn't work when I set the xhr2 constructor name to XMLHttpRequest
and I also needed to add a blank line after the xhr2 import statement. Hope this helps.
from mapbox-gl-directions.
Bumping this thread if anyone has found alternative fixes to the issue.
from mapbox-gl-directions.
Any ideas to fix this issue?
from mapbox-gl-directions.
When I tried the fix it gives me the error:
Class constructor XMLHttpRequest cannot be invoked without 'new'
from mapbox-gl-directions.
Hello, thanks @jeremyrajan . Your solution works form me.
However, I should mention these steps to make it more clear (for my case):
- install xhr2 pkg using yarn or npm
yarn add xhr2
- import it `import xhr2 from "xhr2"
- Then, use the line @jeremyrajan indicates to fix it
global.XMLHttpRequest = xhr2
Thanks
from mapbox-gl-directions.
Hey i have a similar problem in my nextjs application.
I've switched from page to app route and I'm having a problem with just authorization using next-auth and grpc.
I added this code snippet in layout.tsx and still get error.
global.XMLHttpRequest = require("xhr2");
error:
..\node_modules\grpc-web\index.js (18:499) @ self
app:dev: - error Error [ReferenceError]: self is not defined
stack:
next: 13.4.7
next-auth: 4.22.1
react: 18.2.0
xhr2: 0.2.1
from mapbox-gl-directions.
Hey i have a similar problem in my nextjs application. I've switched from page to app route and I'm having a problem with just authorization using next-auth and grpc. I added this code snippet in layout.tsx and still get error.
global.XMLHttpRequest = require("xhr2");error:
..\node_modules\grpc-web\index.js (18:499) @ self app:dev: - error Error [ReferenceError]: self is not definedstack: next: 13.4.7 next-auth: 4.22.1 react: 18.2.0 xhr2: 0.2.1
same problem , have you managed to fixed it yet?
from mapbox-gl-directions.
Related Issues (20)
- Show autocomplete addresses that are close to the users geolocation or map view HOT 1
- Existing route not found HOT 1
- NODE_ENV is undefined, triggers console error in production HOT 6
- Unable to style line colour/width in Directions HOT 2
- setOrigin and setDestination on click HOT 1
- 3 Issues: (1)Text colour issue + (2)Km Vs. Miles + (3)walking directions appearing in the middle of a lake
- Map SetStyle removes direction polyline HOT 1
- Unable to use with MapBox version v2.6.1 HOT 2
- How do you remove picking custom directions with the cursor?
- Missing new params HOT 1
- visualize waypoints
- visualize instructions past first waypoint
- Get duration, distance and weight-name to calculate further
- Error thrown when trying to swap departure and arrival
- [email protected] is not compatible with peer dep [email protected] HOT 8
- Missing TypeScript type definitions for mapbox-gl-directions package
- Get more annotations
- CORS Blocked
- Totally exclude ferries instead of avoiding them
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-gl-directions.