Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can it used with frontend like react ? #60

Open
navneetgarggate6 opened this issue Apr 7, 2021 · 14 comments
Open

Can it used with frontend like react ? #60

navneetgarggate6 opened this issue Apr 7, 2021 · 14 comments

Comments

@navneetgarggate6
Copy link

Can this wrapper used with the front end framework or library like react or angular ?

@JaniAnttonen
Copy link
Owner

Yes, it can be used with any javascript project. :)

@navneetgarggate6
Copy link
Author

I added in my react code but getting following error that's why conforming
image

@JaniAnttonen JaniAnttonen reopened this Apr 7, 2021
@JaniAnttonen
Copy link
Owner

Oh, you're right. This happens because that API is not available in Javascript, only Nodejs. This could be an easy fix, though. Could be fixed by using the url constructor only when it's available, and fall back to just URL strings if not.

@navneetgarggate6
Copy link
Author

navneetgarggate6 commented Apr 7, 2021

log.js:24 [HMR] Waiting for update signal from WDS...
batcher.js:36 http://127.0.0.1:3100/loki/api/v1/push
console.js:128 {"message":"I am a info log from react","level":"info"}
App.js:45 test
request.js:150 POST http://localhost:3001/ 404 (Not Found)
push../node_modules/stream-http/lib/request.js.ClientRequest._onFinish @ request.js:150
(anonymous) @ request.js:62
emit @ events.js:153
finishMaybe @ _stream_writable.js:630
afterWrite @ _stream_writable.js:492
afterTick @ index.js:41
push../node_modules/process/browser.js.Item.run @ browser.js:153
drainQueue @ browser.js:123
setTimeout (async)
runTimeout @ browser.js:41
push../node_modules/process/browser.js.process.nextTick @ browser.js:143
nextTick @ index.js:40
onwrite @ _stream_writable.js:480
WritableState.onwrite @ _stream_writable.js:180
push../node_modules/stream-http/lib/request.js.ClientRequest._write @ request.js:275
doWrite @ _stream_writable.js:428
writeOrBuffer @ _stream_writable.js:417
push../node_modules/readable-stream/lib/_stream_writable.js.Writable.write @ _stream_writable.js:334
(anonymous) @ requests.js:41
post @ requests.js:14
(anonymous) @ batcher.js:202
sendBatchToLoki @ batcher.js:153
run @ batcher.js:227
async function (async)
run @ batcher.js:227
webpackHotDevClient.js:76 The development server has disconnected.
Refresh the page if necessary.
fsUtils.js:11

@navneetgarggate6
Copy link
Author

navneetgarggate6 commented Apr 7, 2021

I fixed above issue now stuck with CORS.
Access to fetch at 'http://127.0.0.1:3100/loki/api/v1/push' from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

@RabbitG29
Copy link

It is occurred in Vue app too.

batcher.js?4c2e:30 Uncaught TypeError: url.URL is not a constructor
    at new Batcher (batcher.js?4c2e:30)
    at new LokiTransport (index.js?43f3:21)
    at eval (LoggingService.ts?05c3:7)
    at Module../src/service/LoggingService.ts (app.js:1707)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=ts&:20)
    at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=ts& (app.js:1019)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)

@yulllll
Copy link

yulllll commented May 27, 2021

Have same error Uncaught TypeError: url.URL is not a constructor

@JaniAnttonen
Copy link
Owner

There's a patch I haven't tested out yet: f863f2a

@tim-mardesen
Copy link

tim-mardesen commented Oct 20, 2021

On this note:
I believe snappy is needed to get this to work, but I can only get snappyjs to install with NPM. I then had to change batcher.js to require snappyjs instead of snappy.

For reference:


./node_modules/winston-loki/src/batcher.js
Module not found: Can't resolve 'snappy' in 'C:\Users\myUser\git\myproject\node_modules\winston-loki\src'```

@kirillito
Copy link

Hi @JaniAnttonen !
I can see that the feature branch for this patch has some conflicts. Is there any chance this patch will be released at some point?

@pshkuro
Copy link

pshkuro commented Nov 2, 2022

Hi, @JaniAnttonen !
The problem is relevant. What do u think about patch?

@JaniAnttonen
Copy link
Owner

Published a new release candidate with the patch under the tag 6.0.7-rc1 and @next, hope it helps. :)

@JaniAnttonen
Copy link
Owner

Have you tried it out? Any issues yet?

@Glazoff
Copy link

Glazoff commented Apr 26, 2023

It works
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants