« first day (3548 days earlier)      last day (1383 days later) » 

3:20 AM
0
Q: Unable to fetch request in react(client-side) and express server

Saumya mishraIam trying to fetch request from backend in form of post and it seems like my backend and frontend are not serving together React SignIn code(Client-side) onSubmitSignIn=()=>{ fetch('http://localhost:3000/signin',{ method:"POST", headers:{'Content-Type':'application/json'}, ...

 
@Codewizard Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
Plz help with this question
 
 
4 hours later…
7:25 AM
Has anyone here worked with AWS WAF?
 
can I use ngZone inside ngZone in angular? is it same or increase performance?
 
8:02 AM
hello. Assume I have an embeddable js which loads a kibana visualization or dashboards ...on the webpage there is script element which is suppose to load this...
<script src="http://foo.different.origin.com/kibana?hash=ab32cf34229dasd"></script>
What if I wanted to proxy authenticate requests to foo.different.origin.com? Based on an http header? How can I pass the header from a script element?
 
js script files behind a authentication wall?
 
yes
 
don't you realize that it's weird?
what you can do is have a filter at your server to serve js files from a specific path only to client requests that are within same domain
and apply a solid CSP policy on the pages that you are serving
 
CSP?
 
CSP stands for "Content Security Policy", an additional measurement you can use on top of Same origin Policy ( SoP)
the js files itself should not contain any sensible data
if you need to use some, serve it from a server and fetch from it
the fetch API has a mechanism to add auth headers to the request
 
8:16 AM
any tutorial videos to this effect?
I am supposed to authenticate a user in the proxy based on a http header...
basically see if the user is logged in the main app...
 
 
2 hours later…
10:29 AM
npm i getting stuck at extract:@types/lodash: sill extract @types/lodash@^4.14.104
This doesn't help
 
Hi
 
@vishal Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
Http://127.0.0.1:8000/min_data/?format=json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)
When I am accessing local host
 
set header Access-Control-Allow-Origin
 
 
7 hours later…
5:18 PM
Morning Afternoon y'all
 
user8729657
@JBis, I pimped out my lab. I'm getting Cisco routers and a new server soon. A monitor, wall and keyboard mount and a RHEL license for 1 year.
 
damn nice
i'm getting a new monitor
 
user8729657
Nice, which one?
 
idk
 
user8729657
I feel you
 
5:24 PM
i want something big and clear, doesn't need to have the gaming features
 
user8729657
I like dual monitors, but a curved monitor seems more efficient.
 
i think more monitors rather then wider ones
and its more cost efficient (i think)
 
6:26 PM
I think I've wasted 10% of my time as a developer purely on lag
 
lag? what are you a game dev?
 
No, a Windows 10 user
(4 GB of RAM, 1 of which is used entirely for audio and 2.8 which is available for everything else)
 
6:42 PM
i suggest you download more ram
 
7:07 PM
Lol
 
omfg, i just received this from a relative:
...a screenshot of the camera app on a phone...of a computer screen...of a google image
 
user8729657
Really you can do that
 
Inception: "We need to go deeper..."
 
user8729657
300 IQ
 
user8729657
Who ever made that app is a legend
 
8:35 PM
I know how to get the file (image) from a file-input and for example preview it
but is it also possible to change the file-input data?
 
How are you wanting to change the data?
The "file" object that you get from a file input is a blob
So you can read it into a bytearray and mess with it that way, if you want to
 
@forresthopkinsa This is almost what I want to do:
64
Q: How to set file input value when dropping file on page?

TristanI'm attempting to make a control where you can both select a file to submit in the form and drop a file into it to do the same thing. I have something like this where it will also show a preview of the file if it's an image: <div class="preview-image-container"> <input type="file" name="File"...

but instead of:
document.querySelector('.image-url').files = ev.dataTransfer.files;
can I set the files = from an url?
(image on same website/server)
"So you can read it into a bytearray and mess with it that way, if you want to"

but can I also write it back?
 
What are you trying to do?
 
ok:
I have a file-input

user selects an image

I display this image

user can crop this image

I write back the cropped data to the file-input so that I can upload it
=> because I can't change the backend
 
How are you planning to crop the image file on the JS side?
 
8:44 PM
I have no idea till now how to do it haha
I know you can write it to a canvas and there select a section
but how to write it then back - no idea
 
Yeah but that'll be a little different
I'm sure there are ways to do binary image manipulation
 
uff
sounds hard
 
Anyways, if we assume that you're manipulating the binary, then sure; read the file out into a blob, and then write it back into the input
Canvas could work but I think that canvas will re-encode the entire image at viewport resolution
 
but from canvas (pixel array??) back to blob its not possible?
 
I'm sure it's possible but I've never done that
It depends on what you're using the image for. If you want to keep the image in its highest quality then I don't think you can do that with Canvas for the reason I mentioned earlier
 
8:47 PM
@Suisse yes this is possible
but its a slight pain
 
Jbis probably knows more about this than I do, I'm gonna dip out
Talk to you guys later
 
hmm so what is the best way?
 
cya forrest
 
thanks forrest!
bb
 
8:48 PM
@Suisse I suggest using the canvas method
I don't think you'll see a quality degradation
 
let's assume I could change the backend..

what I really want is just let the user select an image (or take it from webcam) and then let him crop it and upload it as a file to the server
 
i'd do it client side
 
yeah me too
so ok..

-select file into file-input
-read file into img
-read img into canvas
-crop
-write back into img
till here I know how to do it
 
then your fine
 
hm no I am now as an img.. I want to have it as a file (in this file-input)
 
8:51 PM
Hey guys. I've given myself an "impossible" task and maybe you guys can give me some tips. Working on a Discord bot. The idea: User submits html / css code. Server generates a screenshot of what it would look like on a website and sends the screenshot back.
Now I know how to generate a screenshot like that into a canvas element and how to save that as an image. Problem is, the code is purely server side. There's no DOM available and therefor no canvas to talk to. Hopefully that makes a bit of sense. Perhaps you guys have some ideas on how to approach the issue?
 
@JBis         document.querySelector('.image-url').files = ev.dataTransfer.files;
this .files
what is this for a format exactly? a blob?
 
@JBis Thanks! That might be exactly what I was looking for!
 
FINALLY! Thank you mozilla for finally implementing a feature we've been waiting for for years!
thank you!
 
ok the package solves all his problem hehe.. I was going to propose him to create html file on the server and run it with selenium and taking a screenshot haha
what is it?????
 
8:54 PM
that was my backup plan, but i figured theres probably a lib for waht he wanted
 
there is always a npm pacakge for that!
so what is mozilla solving??
 
I was looking at this: html2canvas.hertzen.com But it requires a DOM and therefor didn't help much, lol
 
@Suisse It used to not check if the TLD was real when you searched something so if you searched "console.log" it would try to go to "http://console.log" instead of searching it on google
took them years to implement that
 
hehe lol ok.. why not using chrome :P
 
8:57 PM
cause fuck google
 
hehe
brave is a good browser
with built in tor
built in adblocker and so on
 
i wonder how many instances of chromium is installed on the average computer
 
built in webwallet (crypto)
 
all electron apps have their own instances, right?
 
yes
heavy
 
9:49 PM
@JBis Got it to work! icecub.nl/result.png :D
 
Budget developer's YouTube screen capture "software":

```
var screenie = document.createElement("canvas");
var capturer = screenie.getContext("2d");
var vidya = document.querySelector("video");

screenie.style.height = screenie.height = vidya.getBoundingClientRect().height;
screenie.style.left = 0;
screenie.style.position = "absolute";
screenie.style.top = 0;
screenie.style.width = screenie.width = vidya.getBoundingClientRect().width;
screenie.style.zIndex = Number.MAX_SAFE_INTEGER - 1;

document.body.appendChild(screenie);
 
10:06 PM
@icecub nice!
|| formatting @Lapys
 
@@Lapys Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
@Lapys in new browsers you can just do vid.captureStream()
 
Ended up using PhantomJS instead. Basically just a browser with no UI running in CLI. Seemed more reliable than some script trying to mimic a browser
 
Yeah that was my backup plan
 
 
1 hour later…
11:39 PM
 

« first day (3548 days earlier)      last day (1383 days later) »