opened
harrychen1
username_0
### Category
- [ ] Enhancement
- [X ] Bug
- [ ] Question
- [ ] Documentation gap/issue

### Version 

Please specify what version of the library you are using: [  1.3.2       ]

Please specify what version(s) of SharePoint you are targeting: [   SharePoint online      ]

*If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.*

### Observed Behavior
Use PnP/Js to create an SharePoint item and then add attachment, run the gulp serve locally, and test with Version 78.0.3904.70 (Official Build) (64-bit), the attach file code failed with error.
"TypeError: Failed to fetch"

Actually the files are attached but it through exception.

This was not happen using previous Chrome version. I've noticed the error people also notice:

More issues reported here:
https://stackoverflow.com/questions/58270663/samesite-warning-chrome-77

A cookie associated with a cross-site resource at <URL> was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at <URL> and <URL>.

It seems we need to add in response header

response.setHeader("Set-Cookie", "HttpOnly;Secure;SameSite=Strict");

However, we are using PnP/JS package and could not set this.

**Can PnP/JS package enhance and ad this header?
response.setHeader("Set-Cookie", "HttpOnly;Secure;SameSite=Strict");**

### Steps to Reproduce
1. Create a spfx project
2. Add code to add item
3. Add code to upload files
4. Run locally gulp serve
5. Use Chrome Version 78.0.3904.70 (Official Build) (64-bit)

You will found the issue.

This also happens sometimes in all SharePoint tenant after code deployed.

This is urgent.

```typescript 
Code sample:
this.web.lists.getByTitle('Pubs').items.add({
        Title: localItem.Title, PubsType: localItem.PubsType
      }).then((iar: ItemAddResult) => {

        var item = this.web.lists.getByTitle('Pubs').items.getById(iar.data.Id);
        if (!(this.state.selectedFile == null) && this.state.selectedFile.length > 0)
        {
          item.attachmentFiles.addMultiple(this.state.selectedFile).then(v => {    
          
          item.update({
            'WorkflowAutoStart': localItem.WorkflowAutoStart
          }).then((result: ItemUpdateResult) => {//Promise< boolean>

            // set messgae after files attached
            this._updateUIAfterSave(true);
            this.setState({
              isChildSectionVisible: false,
              status: ""
            });
          }, (error: any) => {
            // Do not start workflow if attach file failed
            this._updateUIAfterSave(true);

          });

          this._updateUIAfterSave(true);
        }).catch((err) => {
          
**// Always failed here**
            alert('Attachment problem for new Pubs. Please check Pubs list and verift if files attached, if not, please try to attache again. If issue consistent, please contact Pubs support. ' + err);
          }
        });

        ….

Thanks.
TypeError: Failed to fetch when attach files to SharePoint item
issue
created
koltyakov
username_1
@username_0 If I got you right. Nope, PnPjs is the client-side library, we can not add anything to SharePoint API responses headers, we only make consuming the API nicer and easier.
comment
created
patrick-rodgers
username_2
@username_0 - yes looking at this and the SO article you linked the fix is required on the server side. We can't control what/how cookies are sent from the client. You could report this as well to the [sp-dev-docs repo](https://github.com/SharePoint/sp-dev-docs). Sorry this caught you but unfortunately not within our power to fix.
comment
created
harrychen1
username_0
This is ok. I found a way to fix the issue from our end.
comment
closed
harrychen1
username_0
issue